package com.shop2cn.iapi.sqoptrade.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.shop2cn.iapi.sqoptrade.verify.DGSQPlaceOrderVerifyService;
import org.apache.commons.collections.CollectionUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.common.collect.Lists;
import com.shop2cn.iapi.shenqisettlement.parameter.bean.AgentProductBean;
import com.shop2cn.iapi.sqoptrade.parameter.enums.PromotionTypeEnum;
import com.shop2cn.iapi.sqoptrade.parameter.enums.ReduceProdStocksStatusEnum;
import com.shop2cn.iapi.sqoptrade.parameter.enums.RiskControlStatusEnum;
import com.shop2cn.iapi.sqoptrade.parameter.enums.SqSellerRoleEnum;
import com.shop2cn.iapi.sqoptrade.parameter.model.placeorder.MainOrder;
import com.shop2cn.iapi.sqoptrade.parameter.model.placeorder.Order;
import com.shop2cn.iapi.sqoptrade.parameter.model.placeorder.OrderGroup;
import com.shop2cn.iapi.sqoptrade.parameter.model.placeorder.OrderItem;
import com.shop2cn.iapi.sqoptrade.parameter.req.PlaceOrderByApportionedAmountReq;
import com.shop2cn.iapi.sqoptrade.parameter.req.PlaceOrderReq;
import com.shop2cn.iapi.sqoptrade.parameter.utill.Utils;
import com.shop2cn.iapi.sqoptrade.parameter.vo.BizVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.CatalogApportionVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.CouponVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.OrderGroupVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.OrderItemPreApportionVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.OrderItemVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.OrderVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.PickInStoreVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.SellerPromotionVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.TravelerVo;
import com.shop2cn.iapi.sqoptrade.resp.PlaceOrderResp;
import com.shop2cn.iapi.sqoptrade.service.PlaceOrderByApportionedAmountCall;
import com.ymatou.common.lang.CipherUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.business.service.shenqi.CalculateShenqiSellerProfit;
import com.ymttest.business.service.shenqi.DGSQBaseService;
import com.ymttest.business.service.shenqi.DGSQBuildProxyChainCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.business.service.shenqi.SqTradingCallService;
import com.ymttest.business.service.shenqi.SqTradingProductService;
import com.ymttest.database.model.DGUserInfo;
import com.ymttest.database.sharding.db.ext.model.OrderDetailExtPo;
import com.ymttest.database.sharding.db.ext.model.OrderExtPo;
import com.ymttest.database.sharding.db.sharding.model.MainOrderPo;
import com.ymttest.database.sharding.db.sharding.model.OrderBizLogPo;
import com.ymttest.database.sharding.db.sharding.model.OrderBizPo;
import com.ymttest.database.sharding.db.sharding.model.OrderDetailPo;
import com.ymttest.database.sharding.db.sharding.model.OrderDetailPromotionPo;
import com.ymttest.database.sharding.db.sharding.model.OrderDetailSubPo;
import com.ymttest.database.sharding.db.sharding.model.OrderPo;
import com.ymttest.database.sharding.db.sharding.model.OrderTravelerPo;
import com.ymttest.database.sharding.db.sharding.model.ShenqiProxyChainPo;
import com.ymttest.database.sharding.db.sharding.model.ShenqiSellerProfitPo;
import com.ymttest.database.sharding.db.sqlwapper.OrderShardingWapper;
import com.ymttest.database.sharding.db.sqlwapper.OrderWapper;
import com.ymttest.database.sqlwapper.DGUserWapper;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

@Ignore
public class Ts_PlaceOrderByApportionedAmount {

	private static PlaceOrderByApportionedAmountReq placeOrderByApportionedAmountReq;
	private static PlaceOrderByApportionedAmountCall placeOrderByApportionedAmountCall;
	
	private static OrderShardingWapper orderShardingWapper = new OrderShardingWapper();
	private static OrderWapper orderWapper = new OrderWapper();

	private static boolean isSubsidy = false;
	private static long autotest_goodsOwnerId = Long.valueOf(EnvSetup
			.getData("autotest_goodsOwnerId"));

	String key = "1234567890123456";

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("下单接口-带有分摊信息");

		String accountid1;
		try {
			accountid1 = AccountCallServiceV2.getAccountId(20238699);
			AccountCallServiceV2.resetAccount(accountid1, new BigDecimal(
					9000000), new BigDecimal(0));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
		placeOrderByApportionedAmountCall = new PlaceOrderByApportionedAmountCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(placeOrderByApportionedAmountCall.getOpurl());
		orderShardingWapper.activeDeadCommunicationsLink(orderShardingWapper);
	}

	@After
	public void caseDown() {
		Logger.end();

		isSubsidy = false;
		long sellerId = Long.valueOf(EnvSetup.getData("autotest_seller1"));

		try {
			ProductManagerCallServiceV2.batchSetProductOffSale(
					ProductManagerCallServiceV2
							.getAllOnSaleProducts((int) sellerId),
					(int) sellerId);
		} catch (Exception e) {
			Logger.info("批量下架Ts_PlaceOrder创建的商品");
		}
	}

	/**
	 * 
	 * @throws Exception
	 */
	private void verify() throws Exception {

		Logger.verifyEquals(ECode.SUCCESS, placeOrderByApportionedAmountCall.getString("code"),
				"验证code");

		Logger.verifyEquals("0", placeOrderByApportionedAmountCall.getString("bcode"), "验证bcode");

		PlaceOrderResp orderResp = placeOrderByApportionedAmountCall.getPlaceOrderResp();

		Logger.verifyEquals(true, orderResp.getSuccess(), "验证success");

		if (!orderResp.getSuccess()) {

			Logger.fail(new RuntimeException("!!!!!!!!!下单失败！"));
		}

		DGSQPlaceOrderVerifyService placeOrderVerifyService = new DGSQPlaceOrderVerifyService(
				placeOrderByApportionedAmountReq, placeOrderByApportionedAmountCall);

		long mainOrderId = orderResp.getMainOrderId();

		// 校验主单表(main_order)
		verifyMainOrderDb(mainOrderId);

		List<Long> orderIds = orderResp.getOrderIds();

		MainOrder mainOrder = buildOrder();

		List<Order> orders = new ArrayList<Order>();

		for (OrderGroup orderGroup : mainOrder.getOrderGroups())
			orderGroup.getOrders().forEach(temp -> orders.add(temp));

		for (int i = 0; i < orderIds.size(); i++) {

			long orderId = orderIds.get(i);

			Order expectedOrder = orders.get(i);

			OrderPo actualOrder = orderShardingWapper
					.selectOrderbyOrderId(orderIds.get(i));

			// 校验订单表(order)
			verifyOrderDb(expectedOrder, actualOrder);

			// 校验订单扩展表(order_ext)
			verifyOrderExtDb(expectedOrder, orderId);

			List<OrderItem> expectedOrderDetails = expectedOrder
					.getOrderItems();

			List<OrderDetailPo> actualOrderDetails = orderShardingWapper
					.selectOrderDetailbyOrderId(orderId);

			BigDecimal orderTotalPrice = actualOrderDetails
					.stream()
					.map(detail -> detail.getProductPrice().multiply(
							new BigDecimal(detail.getProductCount())))
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			BigDecimal orderFreight = actualOrderDetails
					.stream()
					.filter(detail -> Utils.falseIfNull(detail
							.getFullReductionFreeFreight()) == false)
					.map(detail -> detail.getFreight())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			BigDecimal orderYmtCouponAmount = actualOrderDetails.stream()
					.map(detail -> detail.getYmtCouponAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			BigDecimal orderSellerCouponAmount = actualOrderDetails.stream()
					.map(detail -> detail.getSellerCouponAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);
			
			BigDecimal orderServiceAmount = actualOrderDetails.stream()
					.map(detail -> detail.getServiceAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);
			
			//计算订单的taxFee
			BigDecimal taxFee = expectedOrder.getTaxFee();

			DataUtil.verifyDecimalEquals(actualOrder.getTotalPrice(),
					orderTotalPrice, "验证数据库订单上的TotalPrice为该订单所有商品总价之和");

			DataUtil.verifyDecimalEquals(actualOrder.getFreight(),
					orderFreight, "验证数据库订单上的Freight为该订单所有商品运费之和");

			DataUtil.verifyDecimalEquals(actualOrder.getYmtCouponAmount(),
					orderYmtCouponAmount,
					"验证数据库订单上的总YmatouCouponValue为该订单所有商品平台券之和");

			DataUtil.verifyDecimalEquals(actualOrder.getSellerCouponAmount(),
					orderSellerCouponAmount,
					"验证数据库订单上的总orderSellerCouponAmount为该订单所有商品商家券之和");
			
			DataUtil.verifyDecimalEquals(taxFee, actualOrder.getTaxFee(),
					"验证数据库订单上的总TaxFee为该订单所有商品税费之和");
			
			DataUtil.verifyDecimalEquals(orderServiceAmount, actualOrder.getServiceAmount(),
					"验证数据库订单上的总serviceAmount为该订单所有商品服务费之和");

			if (placeOrderByApportionedAmountReq.getBizSource() != null) {

				BizVo expectedBiz = placeOrderByApportionedAmountReq.getBizSource();

				OrderBizPo actualOrderBiz = orderShardingWapper
						.selectOrderBizbyOrderId(orderId);

				// 校验订单业务来源表order_biz
				placeOrderVerifyService.verifyOrderBizDb(expectedBiz, actualOrderBiz);
			}
			
			// 校验order_biz_log
			verifyOrderBizLogDb(orderId);
			
			// 校验订单商品表(order_detail)
			verifyOrderDetailDb(expectedOrderDetails, actualOrderDetails);
			
			this.verifyShenqiSellerProfit(actualOrder, actualOrderDetails);
			
			if (placeOrderByApportionedAmountReq.getTravelerVos() != null
					&& placeOrderByApportionedAmountReq.getTravelerVos().size() != 0) {

				this.verifyOrderTraveler(placeOrderByApportionedAmountReq.getTravelerVos(),
						orderId, actualOrder.getUserId(),
						actualOrder.getSellerId());
			}
		}
	}
	
	private void verifyOrderBizLogDb(long orderId) {
		
		if (placeOrderByApportionedAmountReq.getShenqiBuyOrderCsId() != null) {
			
			Logger.comment("验证OrderBizLog表");
			
			OrderBizLogPo actualOrderBizLogPo = orderShardingWapper
					.selectOrderBizLogByOrderId(orderId);

			Logger.verifyEquals("SHENQI_CS_BUY_ORDER",
					actualOrderBizLogPo.getBizType(), "验证BizType");
			Logger.verifyEquals(
					String.format("购买订单客服Id：%s",
							placeOrderByApportionedAmountReq.getShenqiBuyOrderCsId()),
					actualOrderBizLogPo.getContent(), "验证content");
		}
	}

	/**
	 * 校验主单表(main_order)
	 * 
	 * @param mainOrderId
	 */
	private void verifyMainOrderDb(long mainOrderId) {

		MainOrderPo actualMainOrder = orderShardingWapper
				.selectMianOrderbyId(mainOrderId);

		Logger.comment(String.format("校验主单表(main_order) mainOrderId:%s",
				mainOrderId));

		Logger.verifyEquals(placeOrderByApportionedAmountReq.getMainOrderId(),
				actualMainOrder.getMainOrderId(), "验证数据库MainOrderId");

		Logger.verifyEquals(placeOrderByApportionedAmountReq.getProxyOrderId(),
				actualMainOrder.getProxyOrderId(), "验证数据库ProxyOrderId");

		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualMainOrder.getAddTime()) < 2,
				"验证数据库AddTime跟系统当前时间差为2分钟内");
		
		DataUtil.verifyDecimalEquals(placeOrderByApportionedAmountReq.getPayDeductAmount(),
				actualMainOrder.getPayDeductAmount(), "验证数据库pay_deduct_amount");

		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualMainOrder.getUpdateTime()) < 2,
				"验证数据库UpdateTime跟系统当前时间差为2分钟内");
	}

	/**
	 * 校验订单表(order)
	 * 
	 * @param expectedOrder
	 * @param actualOrder
	 */
	private void verifyOrderDb(Order expectedOrder, OrderPo actualOrder) {

		Logger.comment(String.format("校验订单表(order) orderId:%s",
				actualOrder.getOrderId()));

		Logger.verifyEquals(placeOrderByApportionedAmountReq.getMainOrderId(),
				actualOrder.getMainOrderId(), "验证数据库MainOrderId");

		Logger.verifyEquals(expectedOrder.getSellerId(),
				actualOrder.getSellerId(), "验证数据库SellerId");
		DataUtil.verifyEquals(expectedOrder.getHunterId(),
				Utils.zeroIfNull(actualOrder.getHunterId()), "验证数据库HunterId");
		DataUtil.verifyEquals(expectedOrder.getHunterOrderType(),
				Utils.zeroIfNull(actualOrder.getHunterOrderType()),
				"验证数据库HunterOrderType");
		DataUtil.verifyDecimalEquals(expectedOrder.getFreight(),
				actualOrder.getFreight(), "验证数据库Freight");

		DataUtil.verifyDecimalEquals(expectedOrder.getOrderVo()
				.getEarnestCardAmount(), actualOrder.getEarnestCardAmount(),
				"验证数据库EarnestCardAmount");
		DataUtil.verifyDateEquals(expectedOrder.getOrderVo()
				.getPaymentStartTime(), actualOrder.getPaymentStartTime(),
				"验证数据库PaymentStartTime");
		DataUtil.verifyDateEquals(expectedOrder.getOrderVo()
				.getPaymentEndTime(), actualOrder.getPaymentEndTime(),
				"验证数据库PaymentEndTime");
		Logger.verifyEquals(false, actualOrder.getCanConfirm(),
				"验证数据库CanConfirm");
		DataUtil.verifyDecimalEquals(expectedOrder.getTaxFee(),
				actualOrder.getTaxFee(), "验证数据库TaxFee");

		DataUtil.verifyDecimalEquals(
				actualOrder
						.getTotalPrice()
						.add(Utils.zeroIfNull(actualOrder.getFreight()))
						.add(Utils.zeroIfNull(actualOrder.getOrderDiscount()))
						.add(Utils.zeroIfNull(actualOrder.getTaxFee()))
						.add(Utils.zeroIfNull(actualOrder.getServiceAmount()))
						.subtract(
								Utils.zeroIfNull(actualOrder
										.getYmtCouponAmount()))
						.subtract(
								Utils.zeroIfNull(actualOrder
										.getSellerCouponAmount()))
						.subtract(
								Utils.zeroIfNull(actualOrder
										.getPromotionAmount()))
						.subtract(Utils.zeroIfNull(actualOrder.getCardAmount()))
						.subtract(
								Utils.zeroIfNull(actualOrder
										.getYmtPromotionAmount())), actualOrder
						.getPayableAmount(), "验证数据库PayableAmount");

		Logger.verifyEquals(expectedOrder.getOrderVo().getLogisticsType()
				.getCode(), actualOrder.getLogisticsType(),
				"验证数据库LogisticsType");
		Logger.verifyEquals(1, actualOrder.getOrderStatus(), "验证数据库OrderStatus");
		Logger.verifyEquals(null, actualOrder.getPaymentId(), "验证数据库PaymentId");
		DataUtil.verifyDecimalEquals(expectedOrder.getTotalProductPrice(),
				actualOrder.getTotalPrice(), "验证数据库TotalPrice");

		DataUtil.verifyDecimalEquals(expectedOrder.getOrderDiscount(),
				actualOrder.getOrderDiscount(), "验证数据库OrderDiscount");

		Logger.verifyEquals(expectedOrder.getYmatouCouponCode(),
				actualOrder.getYmtCouponCode(), "验证数据库YmtCouponCode");

		DataUtil.verifyDecimalEquals(expectedOrder.getYmatouCouponValue(),
				actualOrder.getYmtCouponAmount(), "验证数据库YmtCouponAmount");

		DataUtil.verifyDecimalEquals(expectedOrder.getSellerPromotionAmount(),
				actualOrder.getPromotionAmount(), "验证数据库PromotionAmount");

		Logger.verifyEquals(expectedOrder.getSellerCouponCode(),
				actualOrder.getSellerCouponCode(), "验证数据库SellerCouponCode");

		DataUtil.verifyDecimalEquals(expectedOrder.getSellerCouponValue(),
				actualOrder.getSellerCouponAmount(), "验证数据库SellerCouponAmount");

		DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
				actualOrder.getAccountPaidAmount(), "验证数据库AccountPaidAmount");
		DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
				actualOrder.getThirdpartyPaidAmount(),
				"验证数据库ThirdpartyPaidAmount");

		DataUtil.verifyDecimalEquals(expectedOrder.getCardAmount(),
				actualOrder.getCardAmount(), "验证数据库cardAmount");

		Logger.verifyEquals(Utils.zeroIfNull(placeOrderByApportionedAmountReq.getAddressId()),
				actualOrder.getAddressId(), "验证数据库AddressId");

		Logger.verifyEquals(null, actualOrder.getPaidTime(), "验证数据库PaidTime");
		Logger.verifyEquals(null, actualOrder.getAcceptTime(),
				"验证数据库AcceptTime");
		Logger.verifyEquals(null, actualOrder.getDeliveryTime(),
				"验证数据库DeliveryTime");
		Logger.verifyEquals(null, actualOrder.getReceiveTime(),
				"验证数据库ReceiveTime");
		Logger.verifyEquals(null, actualOrder.getCancelTime(),
				"验证数据库CancelTime");

		Logger.verifyEquals(false, actualOrder.getXloboDelivery(),
				"验证数据库XloboDelivery");
		Logger.verifyEquals(expectedOrder.containsPreSalePrds(),
				actualOrder.getPresale(), "验证数据库Presale");

		Logger.verifyEquals(RiskControlStatusEnum.Unknown.getCode(),
				actualOrder.getRiskStatus(), "验证数据库RiskStatus");

		Logger.verifyEquals(0, actualOrder.getOrderStatusMemo(),
				"验证数据库orderStatusMemo");

		Logger.verifyEquals(false, actualOrder.getLocked(), "验证数据库Locked");
		Logger.verifyEquals(false, actualOrder.getDeleted(), "验证数据库Deleted");

		Logger.verifyEquals(null, actualOrder.getCancelReason(),
				"验证数据库CancelReason");

		Logger.info("时间差为 :" + Utils.calcTimeSpanMin(actualOrder.getAddTime()));
		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualOrder.getAddTime()) < 2,
				"验证数据库AddTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualOrder.getAddTime()) < 2,
				"验证数据库UpdateTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(expectedOrder.getSellerCouponCode(),
				actualOrder.getSellerCouponCode(), "验证数据库SellerCouponCode");
		Logger.verifyEquals(0, actualOrder.getOrderStatusMemo(),
				"验证数据库OrderStatusMemo");

		Logger.verifyEquals(placeOrderByApportionedAmountReq.getUserId(), actualOrder.getUserId(),
				"验证数据库UserId");
		DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
				actualOrder.getThirdpartyDiscount(), "验证数据库ThirdpartyDiscount");
		DataUtil.verifyDecimalEquals(expectedOrder.getOrderVo()
				.getAutoCancelOrderHours(), actualOrder.getAutoCancelHour(),
				"验证数据库AutoCancelHour");
		Logger.verifyEquals(false, actualOrder.getDomesticDelivery(),
				"验证数据库DomesticDelivery");

		Logger.verifyEquals(null, actualOrder.getNewCustomer(),
				"验证数据库NewCustomer");
		Logger.verifyEquals(null, actualOrder.getNewSeller(), "验证数据库NewSeller");

		Logger.verifyEquals(expectedOrder.getOrderVo().isEcommerceFlag(),
				actualOrder.getPredictEcommerce(), "验证数据库PredictEcommerce");

		Logger.verifyEquals(null, actualOrder.getActualEcommerce(),
				"验证数据库ActualEcommerce");

		Logger.verifyEquals(expectedOrder.getGoodsOwnerId(),
				actualOrder.getGoodsOwnerId(), "验证数据库GoodsOwnerId");

		Logger.verifyEquals(placeOrderByApportionedAmountReq.getSalesman(),
				actualOrder.getSalesman(), "验证数据库Salesman");

		Logger.verifyEquals(expectedOrder.getShenqiLogisticsType(),
				actualOrder.getShenqiLogisticsType(),
				"验证数据库ShenqiLogisticsType");
		Logger.verifyEquals(expectedOrder.getCurrency(),
				actualOrder.getCurrency(),
				"验证数据库currency");
		Logger.verifyEquals(expectedOrder.getCurrencySymbol(),
				actualOrder.getCurrencySymbol(),
				"验证数据库currencySymbol");
		Logger.verifyEquals(
				expectedOrder.getOrderVo().getPackageDeliveryType(),
				actualOrder.getPackageDeliveryType(),
				"验证数据库packageDeliveryType");
		
		Logger.verifyEquals(
				placeOrderByApportionedAmountReq.getSupportOfflinePay(),
				actualOrder.getSupportOfflinePay(),
				"验证数据库supportOfflinePay");
		
		Logger.verifyEquals(Utils.falseIfNull(placeOrderByApportionedAmountReq.getShenqiProxyBuyOrder()),
				actualOrder.getShenqiProxyBuyOrder(),
				"验证数据库ShenqiProxyBuyorder");
		
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getCustomSettlementCurrencyType(),
				actualOrder.getCustomSettlementCurrencyType(),
				"验证数据库CustomSettlementCurrencyType");
		
		Logger.verifyEquals(expectedOrder.getOrderVo().getOrderAlias(),
				actualOrder.getOrderAlias(),
				"验证数据库OrderAlias");
		
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getPayChannelType(),
				actualOrder.getPayChannelType(),
				"验证数据库PayChannelType");
		
		Logger.verifyEquals(
				Utils.falseIfNull(placeOrderByApportionedAmountReq.getPickupInStores()),
				actualOrder.getPickupInStores(), "验证数据库PickupInStores");

		Logger.verifyEquals(expectedOrder.getShenqiIdCardRequirement(),
				actualOrder.getShenqiIdcardRequirement(),
				"验证数据库ShenqiIdcardRequirement");
		
		Logger.verifyEquals(
				Utils.falseIfNull(placeOrderByApportionedAmountReq.getPickupInStores()) == true ? false
						: expectedOrder.getShenqiIdCardRequirement() > 0,
				actualOrder.getNeedUploadIdcard(), "验证数据库NeedUploadIdcard");
		
		Logger.verifyEquals(expectedOrder.getOrderVo().getPurchaserIdcardId(),
				actualOrder.getPurchaserIdcardId(),
				"验证数据库PurchaserIdcardId");
		
		if (Utils.zeroIfNull(expectedOrder.getOrderVo().getPurchaserIdcardId()) > 0
				&& Utils.zeroIfNull(expectedOrder.getOrderVo()
						.getShenqiIdCardRequirement()) == 1)
			Logger.verifyEquals(true, actualOrder.getUploadedIdcard(),
					"验证数据库UploadedIdcard");
		
		Logger.verifyEquals(expectedOrder.getOrderVo().getWarehouseId(),
				actualOrder.getWarehouseId(),
				"验证数据库WarehouseId");
		
		Integer totalVStockCount = expectedOrder.getOrderVo().getOrderItems()
				.stream().mapToInt(orderItemVo -> Utils.zeroIfNull(orderItemVo.getVirtualProductNum())).sum();
		
		Logger.verifyEquals(totalVStockCount > 0 ? true : false,
				Utils.falseIfNull(actualOrder.getWaitInStock()),
				"验证数据库WaitInStock");
		Logger.verifyEquals(null, actualOrder.getInStockTime(),
				"验证数据库InStockTime");
		
		// 特殊情况，如果订单被风控且是线下支付的订单RiskOrder为true，一个主单所有子单都为true
		// 风控规则商品单价为20000，3个商品，总价60000
		if (actualOrder.getPayableAmount().compareTo(new BigDecimal("60000.00")) == 0
				&& Utils.falseIfNull(actualOrder.getSupportOfflinePay()))
			Logger.verifyEquals(true, actualOrder.getPlaceRisk(),
					"验证数据库PlaceRisk");
		else
			Logger.verifyEquals(false, actualOrder.getPlaceRisk(),
					"验证数据库PlaceRisk");
	}

	/**
	 * 校验订单扩展表(order_ext)
	 * 
	 * @param actualOrder
	 * @param orderId
	 * @throws Exception
	 */
	private void verifyOrderExtDb(Order actualOrder, long orderId)
			throws Exception {

		// 等待下单回调处理完成
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		String phoneKey = "123456789";
		String addreeKey = "123456789";

		Logger.comment(String.format("校验订单扩展表(order_ext) orderId:%s", orderId));

		OrderExtPo actualOrderExt = orderWapper
				.selectOrderExtByOrderId(orderId);

		if (actualOrderExt == null) {

			Logger.comment("#############Thread.sleep(5000) 下单回调还没处理完");
			Logger.fail(new Exception("Thread.sleep(5000) 下单回调还没处理完"));
			return;

		}

		if (placeOrderByApportionedAmountReq.getAddress() == null
				|| placeOrderByApportionedAmountReq.getAddress().equalsIgnoreCase(""))

			Logger.verifyEquals(placeOrderByApportionedAmountReq.getAddress(),
					actualOrderExt.getUserAddress(), "验证数据库userAddress");
		else {
			Logger.verifyEquals(CipherUtil.encryptAES(addreeKey,
					placeOrderByApportionedAmountReq.getAddress()), actualOrderExt
					.getUserAddress(), "验证数据库userAddress");
			Logger.verifyEquals(placeOrderByApportionedAmountReq.getAddress(),
					Utils.decryptAES(actualOrderExt.getUserAddress()),
					"验证数据库userAddress解密后的数据");
		}

		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualOrderExt.getAddTime()) < 2,
				"验证数据库AddTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualOrderExt.getUpdateTime()) < 2,
				"验证数据库UpdateTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(orderId, actualOrderExt.getOrderId(),
				"验证数据库OrderId");

		Long sellerId = actualOrder.getSellerId();
		Logger.verifyEquals(sellerId, actualOrderExt.getSellerId(),
				"验证数据库SellerId");

		DGUserInfo dgUserInfo = new DGUserWapper().selectDGUserInfo(
				sellerId.intValue()).get(0);

		Logger.verifyEquals(dgUserInfo.getLoginId(),
				actualOrderExt.getSellerLoginId(), "验证数据库SellerLoginId");

		Long userId = placeOrderByApportionedAmountReq.getUserId();

		Logger.verifyEquals(userId, actualOrderExt.getUserId(), "验证数据库UserId");

		Logger.verifyEquals(null, actualOrderExt.getUserLoginId(),
				"验证数据库UserLoginId");

		Logger.verifyEquals(placeOrderByApportionedAmountReq.getDeviceId(),
				actualOrderExt.getDeviceId(), "验证数据库DeviceId");
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getSourceIp(),
				actualOrderExt.getSourceIp(), "验证数据库SourceIp");
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getEquipmentId(),
				actualOrderExt.getEquipmentId(), "验证数据库EquipmentId");
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getPostCode(),
				actualOrderExt.getPostCode(), "验证数据库PostCode");

		Logger.verifyEquals(null, actualOrderExt.getSellerNote(),
				"验证数据库SellerNote");
		Logger.verifyEquals(actualOrder.getOrderVo().getLeaveWord(),
				actualOrderExt.getLeaveWord(), "验证数据库LeaveWord");
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getOrderSource().name(),
				actualOrderExt.getSourcePlatform(), "验证数据库SourcePlatform");

		Logger.verifyEquals(placeOrderByApportionedAmountReq.getAppTerminalSource().name(),
				actualOrderExt.getSourceTerminal(), "验证数据库SourceTerminal");

		Logger.verifyEquals(placeOrderByApportionedAmountReq.getTerminalSource().name(),
				actualOrderExt.getOperatingSystem(), "验证数据库OperatingSystem");

		Logger.verifyEquals(null, actualOrderExt.getSellerNoteLevel(),
				"验证数据库SellerNoteLevel");
		
		// 如果下单有出行人信息，则将第一个出行人的电话、名称写入数据库
		if (placeOrderByApportionedAmountReq.getTravelerVos() != null && placeOrderByApportionedAmountReq.getTravelerVos().size() != 0) {
			
			TravelerVo travelerVo = placeOrderByApportionedAmountReq.getTravelerVos().get(0);
			
			placeOrderByApportionedAmountReq.setRecvMobile(travelerVo.getTravelerPhone());
			placeOrderByApportionedAmountReq.setRecvName(travelerVo.getTravelerName());
		}
		
		if (placeOrderByApportionedAmountReq.getRecvMobile() == null
				|| placeOrderByApportionedAmountReq.getRecvMobile().equalsIgnoreCase(""))

			Logger.verifyEquals(placeOrderByApportionedAmountReq.getRecvMobile(),
					actualOrderExt.getUserPhone(), "验证数据库userPhone");
		else {
			Logger.verifyEquals(
					CipherUtil.encryptAES(phoneKey,
							Utils.trimAndLeft(placeOrderByApportionedAmountReq.getRecvMobile(), 20)),
					actualOrderExt.getUserPhone(), "验证数据库userPhone");

			Logger.verifyEquals(
					CipherUtil.decryptAES(phoneKey, actualOrderExt.getUserPhone()),
					Utils.trimAndLeft(placeOrderByApportionedAmountReq.getRecvMobile(), 20),
					"验证数据库userPhone解密后的数据");
		}

		Logger.verifyEquals(Utils.trimAndLeft(placeOrderByApportionedAmountReq.getRecvName(), 50),
				actualOrderExt.getReceiver(), "验证数据库Receiver");
		
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getEntryIdType(),
				actualOrderExt.getEntryIdType(), "验证数据库EntryIdType");
		DataUtil.verifyDateEquals(placeOrderByApportionedAmountReq.getEntryTime(),
				actualOrderExt.getEntryTime(), "验证数据库EntryTime");
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getEntryIdNo(),
				actualOrderExt.getEntryIdNo(), "验证数据库EntryIdNo");
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getEntryPort(),
				actualOrderExt.getEntryPort(), "验证数据库EntryPort");
		Logger.verifyEquals(placeOrderByApportionedAmountReq.getTransportation(),
				actualOrderExt.getTransportation(), "验证数据库Transportation");
	}

	/**
	 * 校验订单商品表(order_detail)
	 * 
	 * @param expectedOrderDetails
	 * @param actualOrderDetails
	 * @throws InterruptedException 
	 */
	private void verifyOrderDetailDb(List<OrderItem> expectedOrderDetails,
			List<OrderDetailPo> actualOrderDetails) throws InterruptedException {

		for (int i = 0; i < expectedOrderDetails.size(); i++) {

			OrderItem expectedOrderDetail = expectedOrderDetails.get(i);

			OrderDetailPo actualOrderDetail = actualOrderDetails.get(i);
			
			String goodsOwnerCatalogId = null;

			Logger.comment(String.format(
					"校验订单商品表(order_detail) orderId:%s,OrderDetailId:%s",
					actualOrderDetail.getOrderId(),
					actualOrderDetail.getOrderDetailId()));

			DataUtil.verifyDecimalEquals(expectedOrderDetail.getItemVo()
					.getFreight(), actualOrderDetail.getFreight(),
					"验证数据库Freight");

			DataUtil.verifyDecimalEquals(expectedOrderDetail.getItemVo()
					.getBookingPromotionAmount(), actualOrderDetail
					.getBookingPromotionAmount(), "验证数据库BookingPromotionAmount");

			DataUtil.verifyDecimalEquals(expectedOrderDetail.getItemVo()
					.getEarnestAmount(), actualOrderDetail.getEarnestAmount(),
					"验证数据库EarnestAmount");

			Logger.verifyEquals(true,
					Utils.calcTimeSpanMin(actualOrderDetail.getAddTime()) < 2,
					"验证数据库AddTim跟系统当前时间差为2分钟内");

			DataUtil.verifyDecimalEquals(expectedOrderDetail.getItemVo()
					.getProductPrice(), actualOrderDetail.getProductPrice(),
					"验证数据库ProductPrice");

			DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
					actualOrderDetail.getThirdpartyDiscount(),
					"验证数据库ThirdpartyDiscount");

			DataUtil.verifyDecimalEquals(
					expectedOrderDetail.getSellerCouponValue(),
					actualOrderDetail.getSellerCouponAmount(),
					"验证数据库SellerCouponAmount");

			DataUtil.verifyDecimalEquals(
					expectedOrderDetail.getYmatouCouponValue(),
					actualOrderDetail.getYmtCouponAmount(),
					"验证数据库YmtCouponAmount");

			DataUtil.verifyDecimalEquals(expectedOrderDetail.getItemVo()
					.getYmtPromotionAmount(), actualOrderDetail
					.getYmtPromotionAmount(), "验证数据库ymt_promotion_amount");

			DataUtil.verifyDecimalEquals(
					expectedOrderDetail.getSellerPromotionAmount(),
					actualOrderDetail.getPromotionAmount(),
					"验证数据库PromotionAmount");

			Logger.verifyEquals(
					true,
					Utils.calcTimeSpanMin(actualOrderDetail.getUpdateTime()) < 2,
					"验证数据库UpdateTime跟系统当前时间差为2分钟内");

			Logger.verifyEquals(expectedOrderDetail.getItemVo().getProductId(),
					actualOrderDetail.getProductId(), "验证数据库ProductId");

			Logger.verifyEquals(expectedOrderDetail.getItemVo().getCatalogId(),
					actualOrderDetail.getCatalogId(), "验证数据库CatalogId");
			
			goodsOwnerCatalogId = actualOrderDetail.getCatalogId();

			Logger.verifyEquals(expectedOrderDetail.getItemVo()
					.getStockStatus() == null ? 0 : expectedOrderDetail
					.getItemVo().getStockStatus().getCode(), actualOrderDetail
					.getCatalogType(), "验证数据库CatalogType");

			Logger.verifyEquals(
					expectedOrderDetail.getItemVo().getProductNum(),
					actualOrderDetail.getProductCount(), "验证数据库ProductCount");

			if (expectedOrderDetail.getItemVo().getBondedArea() != null) {
				Logger.verifyEquals(expectedOrderDetail.getItemVo()
						.getBondedArea().getCode(),
						actualOrderDetail.getBondedArea(), "验证数据库BondedArea");
			}

			Logger.verifyEquals(
					expectedOrderDetail.getItemVo().getProductVer(),
					actualOrderDetail.getProductSnap(), "验证数据库ProductSnap");

			Logger.verifyEquals(
					expectedOrderDetail.getItemVo().getPriceType() == null ? 0
							: expectedOrderDetail.getItemVo().getPriceType()
									.getCode(), actualOrderDetail
							.getPriceType(), "验证数据库PriceType");

			DataUtil.verifyDecimalEquals(expectedOrderDetail.getItemVo()
					.getOriginalPrice(), actualOrderDetail.getOriginalPrice(),
					"验证数据库OriginalPrice");

			if (isSubsidy) {
				DataUtil.verifyDecimalEquals(BigDecimal.ONE,
						actualOrderDetail.getSubsidyAmount(),
						"验证数据库SubsidyAmount");
			} else {
				DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
						actualOrderDetail.getSubsidyAmount(),
						"验证数据库SubsidyAmount");
			}

			DataUtil.verifyDecimalEquals(expectedOrderDetail.getDiscount(),
					actualOrderDetail.getDiscount(), "验证数据库Discount");

			long activityId = 0, activityTemplateId = 0, productInActivityId = 0;

			if (expectedOrderDetail.getItemVo().getActivity() != null) {

				activityId = expectedOrderDetail.getItemVo().getActivity()
						.getActivityId();

				activityTemplateId = expectedOrderDetail.getItemVo()
						.getActivity().getActivityTemplateId();

				productInActivityId = expectedOrderDetail.getItemVo()
						.getActivity().getProductInActivityId();
			}

			Logger.verifyEquals(activityId,
					Long.valueOf(actualOrderDetail.getActivityId()),
					"验证数据库ActivityId");

			Logger.verifyEquals(
					expectedOrderDetail.getItemVo().getTariffType(),
					actualOrderDetail.getTariffType(), "验证数据库TariffType");

			if (expectedOrderDetail.getItemVo().getProductRefundChannel() != null) {

				Logger.verifyEquals(expectedOrderDetail.getItemVo()
						.getProductRefundChannel().getCode(),
						actualOrderDetail.getRefundChannel(),
						"验证数据库RefundChannel");
			}
			
			if (expectedOrderDetail.getItemVo().getSalesType() != null) {

				Logger.verifyEquals(expectedOrderDetail.getItemVo()
						.getSalesType().getCode(),
						actualOrderDetail.getSalesType(), "验证数据库SalesType");
			}

			Logger.verifyEquals(
					expectedOrderDetail.getItemVo().isFreightFree(),
					actualOrderDetail.getFreeFreight(), "验证数据库FreeFreight");
			Logger.verifyEquals(expectedOrderDetail.getItemVo().isPspProduct(),
					actualOrderDetail.getPspProduct(), "验证数据库PspProduct");
			Logger.verifyEquals(expectedOrderDetail.getItemVo().isSubProduct(),
					actualOrderDetail.getSubProduct(), "验证数据库SubProduct");

			Logger.verifyEquals(expectedOrderDetail.getItemVo()
					.getFirstCategoryId(), Long.valueOf(actualOrderDetail
					.getFirstCategoryId()), "验证数据库FirstCategoryId");
			Logger.verifyEquals(expectedOrderDetail.getItemVo()
					.getSecondCategoryId(), Long.valueOf(actualOrderDetail
					.getSecondCategoryId()), "验证数据库SecondCategoryId");

			Logger.verifyEquals(expectedOrderDetail.getItemVo()
					.getThirdCategoryId(), Long.valueOf(actualOrderDetail
					.getThirdCategoryId()), "验证数据库ThirdCategoryId");

			Logger.verifyEquals(activityTemplateId,
					Long.valueOf(actualOrderDetail.getActivityTempId()),
					"验证数据库ActivityTempId");

			Logger.verifyEquals(productInActivityId,
					Long.valueOf(actualOrderDetail.getProductInActivityId()),
					"验证数据库ProductInActivityId");

			Logger.verifyEquals(expectedOrderDetail.getItemVo()
					.isSupportsRtnWithoutReason(), actualOrderDetail
					.getSupportNoReasonRefund(), "验证数据库SupportNoReasonRefund");

			if (expectedOrderDetail.getSellerPromotion() != null) {

				OrderDetailPromotionPo actualOrderDetailPromotion = orderShardingWapper
						.selectOrderDetailPromotionByOrderDetailId(actualOrderDetail
								.getOrderDetailId());

				// 校验订单营销表（order_detail_promotion）
				verifyOrderDetailPromotionDb(expectedOrderDetail,
						actualOrderDetailPromotion,
						actualOrderDetail.getOrderId());
			}
			
//			boolean fullReductionFreeFreight = Utils.falseIfNull(actualOrderDetail.getFullReductionFreeFreight());
			
			int scale = 2;
			
			if (null != placeOrderByApportionedAmountReq.getCurrency()
					&& placeOrderByApportionedAmountReq.getCurrency()
							.equalsIgnoreCase("JPY"))
				scale = 0;

			// 直销商没有代理价，有代理价的情况才会查询代理链
			if (null != actualOrderDetail.getProxyPrice()) {

				long sellerId = placeOrderByApportionedAmountReq.getOrderGroups().get(0).getSellerId();
				String catalogId = actualOrderDetail.getCatalogId();
				
				boolean isInherited = GodmchManageCallService.isInheritedAgent(sellerId);
				
				// 校验神器链条表
				List<ShenqiProxyChainPo> expectedShenqiProxyChainPoList = isInherited ? SqTradingProductService
						.getInheritedProxyChainInfo(catalogId, sellerId)
						: SqTradingProductService
								.getProxyChainInfoList(catalogId, sellerId);

				expectedShenqiProxyChainPoList
						.get(expectedShenqiProxyChainPoList.size() - 1)
						.setPictureUrl(
								expectedOrderDetail.getItemVo().getPictureUrl());
				expectedShenqiProxyChainPoList.get(
						expectedShenqiProxyChainPoList.size() - 1).setTitle(
						expectedOrderDetail.getItemVo().getProductName());

				Logger.verifyEquals(
						expectedShenqiProxyChainPoList.get(
								expectedShenqiProxyChainPoList.size() - 1)
								.getFromParentPrice(), actualOrderDetail
								.getProxyPrice(), "验证数据库ProxyPrice");

				this.verifyShenqiProxyChainDb(expectedShenqiProxyChainPoList,
						actualOrderDetail.getOrderId(),
						actualOrderDetail.getCatalogId());
				
				goodsOwnerCatalogId = expectedShenqiProxyChainPoList.get(0)
						.getProxyCatalogId();
				
				DataUtil.verifyDecimalEquals(null,
						actualOrderDetail.getServiceRate(), "验证数据库ServiceRate");
				DataUtil.verifyDecimalEquals(null,
						actualOrderDetail.getServiceAmount(),
						"验证数据库serviceAmount");
			} else {
				
				BigDecimal serviceRate = expectedOrderDetail.getServiceRate();
				BigDecimal serviceAmount = SqTradingCallService.getServiceAmount(actualOrderDetail);
				
				// 直销订单验证服务费
				DataUtil.verifyDecimalEquals(Utils.zeroIfNull(serviceRate),
						actualOrderDetail.getServiceRate(), "验证数据库ServiceRate");
				DataUtil.verifyDecimalEquals(
						serviceAmount.setScale(scale, BigDecimal.ROUND_HALF_UP),
						actualOrderDetail.getServiceAmount(),
						"验证数据库serviceAmount");
			}
			
			DataUtil.verifyDecimalEquals(Utils.zeroIfNull(expectedOrderDetail.getItemVo()
					.getProdTaxRate()), actualOrderDetail.getTaxRate(),
					"验证数据库TaxRate");
			
			BigDecimal taxFee = BigDecimal.ZERO;
			
			if (null != expectedOrderDetail.getItemVo().getOrderItemPreApportionVo()) {
				
				OrderItemPreApportionVo orderItemPreApportionVo = expectedOrderDetail
						.getItemVo().getOrderItemPreApportionVo();
				
				taxFee = Utils.zeroIfNull(orderItemPreApportionVo.getTaxFee())
						.divide(new BigDecimal(actualOrderDetail.getProductCount()), scale,
								BigDecimal.ROUND_HALF_UP);
			}
			
			if (SqTradingCallService.isFreePerimeters(placeOrderByApportionedAmountReq.getAddress()))
				DataUtil.verifyDecimalEquals(BigDecimal.ZERO, actualOrderDetail.getTaxFee(), "验证数据库TaxFee");
			else
				DataUtil.verifyDecimalEquals(taxFee, actualOrderDetail.getTaxFee(), "验证数据库TaxFee");
			
			Logger.verifyEquals(expectedOrderDetail.getItemVo()
					.isBuyDailyLimit(), actualOrderDetail.isDailyLimit(),
					"验证数据库DailyLimit");
			
			DataUtil.verifyDecimalEquals(expectedOrderDetail.getItemVo()
					.getVirtualProductNum(), Utils.zeroIfNull(actualOrderDetail
					.getvStockCount()), "验证数据库vStockCount");
			
			Logger.verifyEquals(expectedOrderDetail.getItemVo()
					.getDomesticProduct(), actualOrderDetail
					.getDomesticProduct(), "验证数据库DomesticProduct");
			
			Logger.verifyEquals(Utils.zeroIfNull(actualOrderDetail
					.getvStockCount()) > 0 ? true : false, Utils.falseIfNull(actualOrderDetail
							.getWaitInStock()), "验证数据库WaitInStock");
			Logger.verifyEquals(goodsOwnerCatalogId, actualOrderDetail
					.getGoodsOwnerCatalogId(), "验证数据库GoodsOwnerCatalogId");
			Logger.verifyEquals(null, actualOrderDetail
					.getInStockTime(), "验证数据库InStockTime");
			
			// 校验订单商品扩展表(order_detail_ext)
			verifyOrderDetailExtDb(expectedOrderDetail, actualOrderDetail);

			// 订单商品是 套装商品
			if (expectedOrderDetail.getItemVo().isSubProduct()) {

				// 校验订单组合子商品表（order_detail_sub）
				verifyOrderDetailSubDb(actualOrderDetail);
			}
		}
	}

	/**
	 * 校验营销表（order_detail_promotion）
	 * 
	 * @param expectedOrderItem
	 * @param actualOrderDetailPromotion
	 */
	private void verifyOrderDetailPromotionDb(OrderItem expectedOrderItem,
			OrderDetailPromotionPo actualOrderDetailPromotion, long orderId) {

		Logger.comment(String.format(
				"校验营销表（order_detail_promotion）orderId:%s orderDetailId:%s",
				orderId, actualOrderDetailPromotion.getOrderDetailId()));

		SellerPromotionVo expectedSellerPromotion = expectedOrderItem
				.getSellerPromotion();

		Logger.verifyEquals(
				true,
				Utils.calcTimeSpanMin(actualOrderDetailPromotion.getAddTime()) < 2,
				"验证数据库AddTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualOrderDetailPromotion
						.getUpdateTime()) < 2, "验证数据库UpdateTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(orderId, actualOrderDetailPromotion.getOrderId(),
				"验证数据库OrderId");

		Logger.verifyEquals(expectedOrderItem.getItemVo().getCatalogId(),
				actualOrderDetailPromotion.getCatalogId(), "验证数据库CatalogId");

		DataUtil.verifyDecimalEquals(
				expectedSellerPromotion.getReducedAmount(),
				actualOrderDetailPromotion.getReducedAmount(),
				"验证数据库ReducedAmount");

		Logger.verifyEquals(expectedSellerPromotion.getId(),
				Long.valueOf(actualOrderDetailPromotion.getPromotionId()),
				"验证数据库PromotionId");
		Logger.verifyEquals(expectedSellerPromotion.getType().getCode(),
				actualOrderDetailPromotion.getPromotionType(),
				"验证数据库PromotionType");
		Logger.verifyEquals(expectedSellerPromotion.getName(),
				actualOrderDetailPromotion.getPromotionName(),
				"验证数据库PromotionName");

		Logger.verifyEquals(
				String.valueOf(expectedSellerPromotion.getPromotionValue()),
				actualOrderDetailPromotion.getPromotionValue(),
				"验证数据库PromotionValue");

		String condition = null;

		if (expectedSellerPromotion.getQtyCondition() > 0) {
			condition = "" + expectedSellerPromotion.getQtyCondition();
		} else if (expectedSellerPromotion.getAmountCondition() != null) {
			condition = "" + expectedSellerPromotion.getAmountCondition();
		}

		Logger.verifyEquals(condition,
				actualOrderDetailPromotion.getMatchCondition(),
				"验证数据库MatchCondition");
	}

	/**
	 * 校验订单商品扩展表(order_detail_ext)
	 * 
	 * @param expectedOrderDetail
	 * @param actualOrderDetail
	 */
	private void verifyOrderDetailExtDb(OrderItem expectedOrderDetail,
			OrderDetailPo actualOrderDetail) {

		Long orderDetailId = actualOrderDetail.getOrderDetailId();

		Logger.comment(String.format(
				"校验订单商品表扩展表(order_detail_ext) orderId:%s,OrderDetailId:%s",
				actualOrderDetail.getOrderId(), orderDetailId));

		OrderDetailExtPo actualOrderDetailExt = orderWapper
				.selectOrderDetailExtByOrderId(actualOrderDetail
						.getOrderDetailId());

		Logger.verifyEquals(orderDetailId,
				actualOrderDetailExt.getOrderDetailId(), "验证数据库OrderDetailId");
		Logger.verifyEquals(actualOrderDetail.getCatalogId(),
				actualOrderDetailExt.getCatalogId(), "验证数据库CatalogId");

		Logger.verifyEquals(
				true,
				Utils.calcTimeSpanMin(actualOrderDetailExt.getUpdateTime()) < 2,
				"验证数据库UpdateTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualOrderDetailExt.getAddTime()) < 2,
				"验证数据库AddTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(actualOrderDetail.getOrderId(),
				actualOrderDetailExt.getOrderId(), "验证数据库OrderId");
		Logger.verifyEquals(expectedOrderDetail.getItemVo().getProperty(),
				actualOrderDetailExt.getPropertyInfo(), "验证数据库PropertyInfo");
		Logger.verifyEquals(expectedOrderDetail.getItemVo().getBrandId(),
				actualOrderDetailExt.getBrandId(), "验证数据库BrandId");
		Logger.verifyEquals(expectedOrderDetail.getItemVo().getPictureUrl(),
				actualOrderDetailExt.getPictureUrl(), "验证数据库PictureUrl");
		Logger.verifyEquals(expectedOrderDetail.getItemVo().getSku(),
				actualOrderDetailExt.getSku(), "验证数据库Sku");
		Logger.verifyEquals(expectedOrderDetail.getItemVo().getProductName(),
				actualOrderDetailExt.getTitle(), "验证数据库Title");
		Logger.verifyEquals(expectedOrderDetail.getItemVo()
				.getProductRecordNo(), actualOrderDetailExt.getRecordNo(),
				"验证数据库RecordNo");
	}

	/**
	 * 校验订单组合子商品表（order_detail_sub）
	 *
	 * @param actualOrderDetail
	 */
	private void verifyOrderDetailSubDb(OrderDetailPo actualOrderDetail) {

		long orderDetailId = actualOrderDetail.getOrderDetailId();
		long orderId = actualOrderDetail.getOrderId();

		List<OrderDetailSubPo> subPoList = orderShardingWapper
				.selectOrderDetailSubByDetailId(orderDetailId);

		String catalogId = actualOrderDetail.getCatalogId();

		if (CollectionUtils.isEmpty(subPoList)) {

			String msg = String
					.format("校验订单组合子商品表（order_detail_sub） orderId:%s,catalogId:%s 套装子商品为null",
							actualOrderDetail.getOrderId(), catalogId);
			Logger.comment(msg);

			Logger.fail(new Exception(msg));

			return;
		}

		Logger.comment(String.format(
				"校验订单组合子商品表（order_detail_sub） orderId:%s,catalogId:%s",
				actualOrderDetail.getOrderId(), catalogId));

		BigDecimal fProductPrice = actualOrderDetail.getProductPrice();

		int iAmount = actualOrderDetail.getProductCount();

		BigDecimal fFreight = actualOrderDetail.getFreight();

		BigDecimal fSellerCouponAmount = actualOrderDetail
				.getSellerCouponAmount();

		BigDecimal fYmtCouponAmount = actualOrderDetail.getYmtCouponAmount();

		BigDecimal fSellerPromotionAmount = actualOrderDetail
				.getPromotionAmount();
		// 商品平台优惠金额
		BigDecimal fymtPromotionAmount = actualOrderDetail
				.getYmtPromotionAmount();

		BigDecimal[] weight = new BigDecimal[subPoList.size()];

		for (int j = 0; j < subPoList.size(); j++) {

			OrderDetailSubPo orderInfoSubPo = subPoList.get(j);

			weight[j] = orderInfoSubPo.getOriginalPrice().multiply(
					new BigDecimal(orderInfoSubPo.getProductCount()));
		}

		BigDecimal price[] = Utils.apportionByWeights(
				fProductPrice.multiply(new BigDecimal(iAmount)), weight);

		BigDecimal freight[] = Utils.apportionByWeights(fFreight, weight);

		BigDecimal sellerCoupon[] = Utils.apportionByWeights(
				fSellerCouponAmount, weight);

		BigDecimal ymtCoupon[] = Utils.apportionByWeights(fYmtCouponAmount,
				weight);

		BigDecimal sellerPromotionAmount[] = Utils.apportionByWeights(
				fSellerPromotionAmount, weight);

		BigDecimal ymtPromotionAmount[] = Utils.apportionByWeights(
				fymtPromotionAmount, weight);

		int k = 0;

		for (OrderDetailSubPo actualOrderDetailSub : subPoList) {

			Logger.comment(String.format("套装子商品序号 %s",
					actualOrderDetailSub.getId()));

			Logger.verifyEquals(orderId, actualOrderDetailSub.getOrderId(),
					"验证数据库OrderId");

			Logger.verifyEquals(orderDetailId,
					actualOrderDetailSub.getOrderDetailId(),
					"验证数据库OrderDetailId");

			Logger.verifyEquals(freight[k], actualOrderDetailSub.getFreight(),
					"验证数据库Freight");

			Logger.verifyEquals(
					true,
					Utils.calcTimeSpanMin(actualOrderDetailSub.getAddTime()) < 2,
					"验证数据库AddTime跟系统当前时间差为2分钟内");

			Logger.verifyEquals(
					true,
					Utils.calcTimeSpanMin(actualOrderDetailSub.getUpdateTime()) < 2,
					"验证数据库UpdateTime跟系统当前时间差为2分钟内");

			DataUtil.verifyDecimalEquals(sellerPromotionAmount[k],
					actualOrderDetailSub.getPromotionAmount(),
					"验证数据库PromotionAmount");

			DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
					actualOrderDetailSub.getThirdpartyDiscount(),
					"验证数据库ThirdpartyDiscount");

			Logger.verifyEquals(catalogId, actualOrderDetailSub.getCatalogId(),
					"验证数据库CatalogId");

			DataUtil.verifyDecimalEquals(ymtCoupon[k],
					actualOrderDetailSub.getYmtCouponAmount(),
					"验证数据库YmtCouponAmount");

			DataUtil.verifyDecimalEquals(sellerCoupon[k],
					actualOrderDetailSub.getSellerCouponAmount(),
					"验证数据库SellerCouponAmount");

			DataUtil.verifyDecimalEquals(ymtPromotionAmount[k],
					actualOrderDetailSub.getYmtPromotionAmount(),
					"验证数据库ymtPromotionAmount");

			DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
					actualOrderDetailSub.getDiscount(), "验证数据库Discount");

			DataUtil.verifyDecimalEquals(price[k],
					actualOrderDetailSub.getProductPrice(), "验证数据库ProductPrice");

			k++;
		}
	}

	/**
	 * 校验神器代理链表（shenqi_proxy_chain）
	 * 
	 * @param expectedShenqiProxyChainPoList
	 * @param orderId
	 * @param catalogId
	 */
	private void verifyShenqiProxyChainDb(
			List<ShenqiProxyChainPo> expectedShenqiProxyChainPoList,
			long orderId, String catalogId) {
		orderShardingWapper.clearCache();
		List<ShenqiProxyChainPo> actualShenqiProxyChainPoList = orderShardingWapper
				.selectProxyChainbyOrderIdAndCatalogId(orderId, catalogId);

		for (int i = 0; i < expectedShenqiProxyChainPoList.size(); i++) {

			long sellerId = expectedShenqiProxyChainPoList.get(i).getSellerId();
			
			Logger.comment("校验神器链条表orderId:" + orderId + ", index:"
					+ expectedShenqiProxyChainPoList.get(i).getIndexInChain());
			Logger.verifyEquals(orderId, actualShenqiProxyChainPoList.get(i)
					.getOrderId(), "验证数据库orderId");
			Logger.verifyEquals(catalogId, actualShenqiProxyChainPoList.get(i)
					.getCatalogId(), "验证数据库catalogId");
			Logger.verifyEquals(expectedShenqiProxyChainPoList.get(i)
					.getTitle(),
					actualShenqiProxyChainPoList.get(i).getTitle(),
					"验证数据库title");
			Logger.verifyEquals(expectedShenqiProxyChainPoList.get(i)
					.getPictureUrl(), actualShenqiProxyChainPoList.get(i)
					.getPictureUrl() == null ? ""
					: actualShenqiProxyChainPoList.get(i).getPictureUrl(),
					"验证数据库PictureUrl");
			Logger.verifyEquals(expectedShenqiProxyChainPoList.get(i)
					.getFromParentPrice(), actualShenqiProxyChainPoList.get(i)
					.getFromParentPrice(), "验证数据库FromParentPrice");
			Logger.verifyEquals(expectedShenqiProxyChainPoList.get(i)
					.getToChildPrice(), actualShenqiProxyChainPoList.get(i)
					.getToChildPrice(), "验证数据库ToChildPrice");
			Logger.verifyEquals(expectedShenqiProxyChainPoList.get(i)
					.getIndexInChain(), actualShenqiProxyChainPoList.get(i)
					.getIndexInChain(), "验证数据库IndexInChain");
			Logger.verifyEquals(sellerId, actualShenqiProxyChainPoList.get(i)
					.getSellerId(), "验证数据库SellerId");
			Logger.verifyEquals(true, Utils
					.calcTimeSpanMin(actualShenqiProxyChainPoList.get(i)
							.getAddTime()) < 2, "验证数据库AddTime跟系统当前时间差为2分钟内");
			Logger.verifyEquals(true, Utils
					.calcTimeSpanMin(actualShenqiProxyChainPoList.get(i)
							.getUpdateTime()) < 2,
					"验证数据库UpdateTime跟系统当前时间差为2分钟内");

			if (expectedShenqiProxyChainPoList.size() == (i + 1))
				Logger.verifyEquals(0L, actualShenqiProxyChainPoList.get(i)
						.getChildSellerId(), "验证数据库ChildSellerId");
			else
				Logger.verifyEquals(expectedShenqiProxyChainPoList.get(i + 1)
						.getSellerId(), actualShenqiProxyChainPoList.get(i)
						.getChildSellerId(), "验证数据库ChildSellerId");
			
			Logger.verifyEquals(expectedShenqiProxyChainPoList.get(i)
					.getProxyCatalogId(), actualShenqiProxyChainPoList.get(i)
					.getProxyCatalogId(), "验证数据库ProxyCatalogId");
			
			Logger.verifyEquals(expectedShenqiProxyChainPoList.get(i)
					.getFromParentPriceType(), actualShenqiProxyChainPoList.get(i)
					.getFromParentPriceType(), "验证数据库FromParentPriceType");
			Logger.verifyEquals(Utils
					.falseIfNull(expectedShenqiProxyChainPoList.get(i)
							.getIsFenxiaoShop()), actualShenqiProxyChainPoList
					.get(i).getIsFenxiaoShop(), "验证数据库IsFenxiaoShop");
		}
	}
	
	public void verifyShenqiSellerProfit(OrderPo orderPo,
			List<OrderDetailPo> orderDetailList) {

		long orderId = orderPo.getOrderId();
		BigDecimal payableAmount = orderPo.getPayableAmount();

		if (orderPo.getSellerId() == orderPo.getGoodsOwnerId()) {

			ShenqiSellerProfitPo expectShenqiSellerProfitPo = new ShenqiSellerProfitPo();

			expectShenqiSellerProfitPo.setOrderId(orderId);
			expectShenqiSellerProfitPo.setSellerId(orderPo.getSellerId());
			expectShenqiSellerProfitPo.setSellerRole(3);
			expectShenqiSellerProfitPo.setProfit(payableAmount.subtract(Utils
					.zeroIfNull(orderPo.getServiceAmount())));
			expectShenqiSellerProfitPo.setChildSellerId(0L);

			this.verifyShenqiSellerProfitDb(expectShenqiSellerProfitPo,
					orderId, orderPo.getSellerId());
		} else {

			boolean isInherited = GodmchManageCallService
					.isInheritedAgent(orderPo.getSellerId());

			// 所有规格的代理链条都是一样的，所以取其中一个规格获取所需的seller数量
			List<ShenqiProxyChainPo> shenqiProxyChain = isInherited ? SqTradingProductService
					.getInheritedProxyChainInfo(orderDetailList.get(0)
							.getCatalogId(), orderPo.getSellerId())
					: SqTradingProductService
							.getProxyChainInfoList(orderDetailList.get(0)
									.getCatalogId(), orderPo.getSellerId());

			// 客服的收入
			BigDecimal serviceIncome = BigDecimal.ZERO;

			BigDecimal taxFee = orderDetailList
					.stream()
					.map(p -> p.getTaxFee().multiply(
							new BigDecimal(p.getProductCount())))
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 代理订单的运费不从订单上取，订单上的运费会被fullReductionFreeFreight影响
			BigDecimal freight = orderDetailList.stream()
					.map(p -> p.getFreight())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			int i = 1;

			// 店主的总收入
			BigDecimal shopOwnerTotalProfit = BigDecimal.ZERO;
			// 货头的总收入
			BigDecimal goodsOwnerTotalProfit = BigDecimal.ZERO;
			// 中间商的总收入
			BigDecimal middlerManTotalProfit = BigDecimal.ZERO;

			for (ShenqiProxyChainPo chainPo : shenqiProxyChain) {

				ShenqiSellerProfitPo expectShenqiSellerProfitPo = new ShenqiSellerProfitPo();

				// 如果是货头
				if (chainPo.getIndexInChain() == 0
						&& orderPo.getSellerId() != orderPo.getGoodsOwnerId()) {

					// 货头的总收入
					goodsOwnerTotalProfit = CalculateShenqiSellerProfit
							.calProductTotalProfit(orderDetailList,
									isInherited, chainPo, shenqiProxyChain,
									orderPo, i, taxFee, freight,
									SqSellerRoleEnum.GoodOwner.getCode(), null);

					expectShenqiSellerProfitPo.setSellerRole(2);
				}
				// 如果是店主
				else if (chainPo.getSellerId().longValue() == orderPo
						.getSellerId().longValue()) {

					// 店主的总收入
					shopOwnerTotalProfit = CalculateShenqiSellerProfit
							.calProductTotalProfit(orderDetailList,
									isInherited, chainPo, shenqiProxyChain,
									orderPo, i, taxFee, freight,
									SqSellerRoleEnum.ShopOwner.getCode(), null);

					expectShenqiSellerProfitPo.setSellerRole(1);
				}
				// 如果是中间商
				else {

					// 中间商的总收入
					middlerManTotalProfit = CalculateShenqiSellerProfit
							.calProductTotalProfit(orderDetailList,
									isInherited, chainPo, shenqiProxyChain,
									orderPo, i, taxFee, freight,
									SqSellerRoleEnum.MiddlerMan.getCode(), null);

					expectShenqiSellerProfitPo.setSellerRole(4);
				}

				if (isInherited) {

					// 如果是继承代理，需要提前知道店主的利润
					shopOwnerTotalProfit = CalculateShenqiSellerProfit
							.calProductTotalProfit(orderDetailList,
									isInherited, chainPo, shenqiProxyChain,
									orderPo, i, taxFee, freight,
									SqSellerRoleEnum.ShopOwner.getCode(), null);

					if (shenqiProxyChain.size() >= 3) {

						goodsOwnerTotalProfit = goodsOwnerTotalProfit.add(
								taxFee).add(freight);

						if (shenqiProxyChain.size() - 1 == i) {

							// 优惠总额：买手优惠券 + 买手满减优惠
							BigDecimal totalPromotion = orderPo
									.getPromotionAmount().add(
											orderPo.getSellerCouponAmount());

							middlerManTotalProfit = middlerManTotalProfit
									.add(orderPo.getOrderDiscount())
									.subtract(freight)
									.add(orderPo.getFreight())
									.subtract(shopOwnerTotalProfit)
									.subtract(totalPromotion);
							expectShenqiSellerProfitPo
									.setSubDistributionProfit(shopOwnerTotalProfit
											.setScale(2, BigDecimal.ROUND_DOWN));
						}
					} else {

						goodsOwnerTotalProfit = orderPo.getPayableAmount()
								.subtract(shopOwnerTotalProfit);

						if (shenqiProxyChain.size() - 1 == i)
							expectShenqiSellerProfitPo
									.setSubDistributionProfit(shopOwnerTotalProfit);
					}
				} else {

					// 优惠总额：买手优惠券 + 买手满减优惠
					BigDecimal totalPromotion = orderPo.getPromotionAmount()
							.add(orderPo.getSellerCouponAmount());

					shopOwnerTotalProfit = shopOwnerTotalProfit
							.add(orderPo.getOrderDiscount())
							.subtract(totalPromotion).subtract(freight)
							.add(orderPo.getFreight());
					goodsOwnerTotalProfit = goodsOwnerTotalProfit.add(freight)
							.add(taxFee);
				}

				expectShenqiSellerProfitPo.setOrderId(orderId);
				expectShenqiSellerProfitPo.setSellerId(chainPo.getSellerId());
				expectShenqiSellerProfitPo.setChildSellerId(chainPo
						.getChildSellerId());

				// 如果是货头
				if (chainPo.getIndexInChain() == 0
						&& orderPo.getSellerId() != orderPo.getGoodsOwnerId()) {

					expectShenqiSellerProfitPo.setProfit(goodsOwnerTotalProfit);
				}
				// 如果是店主
				else if (chainPo.getSellerId().longValue() == orderPo
						.getSellerId().longValue()) {

					expectShenqiSellerProfitPo.setProfit(shopOwnerTotalProfit);
				}
				// 如果是中间商
				else {

					expectShenqiSellerProfitPo.setProfit(middlerManTotalProfit);
				}

				serviceIncome = expectShenqiSellerProfitPo.getProfit();

				this.verifyShenqiSellerProfitDb(expectShenqiSellerProfitPo,
						orderId, expectShenqiSellerProfitPo.getSellerId());

				i = i + 1;
			}

			if (orderPo.getSalesman() != 0) {

				ShenqiSellerProfitPo expectShenqiSellerProfitPo = new ShenqiSellerProfitPo();

				expectShenqiSellerProfitPo.setOrderId(orderId);
				expectShenqiSellerProfitPo.setSellerId(orderPo.getSalesman());
				expectShenqiSellerProfitPo.setSellerRole(5);
				expectShenqiSellerProfitPo.setProfit(serviceIncome);
				expectShenqiSellerProfitPo.setChildSellerId(0L);

				this.verifyShenqiSellerProfitDb(expectShenqiSellerProfitPo,
						orderId, orderPo.getSalesman());
			}
		}
	}
	
	/**
	 * 校验神器卖家利润表（shenqi_seller_profit）
	 * 
	 * @param expectShenqiSellerProfitPo
	 * @param orderId
	 * @param sellerId
	 */
	private void verifyShenqiSellerProfitDb(
			ShenqiSellerProfitPo expectShenqiSellerProfitPo, long orderId,
			long sellerId) {
		
		orderShardingWapper.clearCache();
		
		Logger.comment(String.format("开始验证sellerId：%s，在orderId：%s 上获得的利润", sellerId, orderId));
		
		ShenqiSellerProfitPo actualShenqiSellerProfitPo = orderShardingWapper
				.selectSellerProfitbyOrderIdAndSellerId(orderId, sellerId);

		Logger.verifyEquals(expectShenqiSellerProfitPo.getOrderId(),
				actualShenqiSellerProfitPo.getOrderId(), "验证orderId");
		Logger.verifyEquals(expectShenqiSellerProfitPo.getSellerId(),
				actualShenqiSellerProfitPo.getSellerId(), "验证sellerId");
		DataUtil.verifyDecimalEquals(expectShenqiSellerProfitPo.getProfit(),
				actualShenqiSellerProfitPo.getProfit(), "验证profit");
		Logger.verifyEquals(expectShenqiSellerProfitPo.getSellerRole(),
				actualShenqiSellerProfitPo.getSellerRole(), "验证sellerRole");
		Logger.verifyEquals(expectShenqiSellerProfitPo.getChildSellerId(),
				actualShenqiSellerProfitPo.getChildSellerId(), "验证childSellerId");
		Logger.verifyEquals(expectShenqiSellerProfitPo.getSubDistributionProfit(),
				actualShenqiSellerProfitPo.getSubDistributionProfit(), "验证subDistributionProfit");
	}
	
	public void verifyOrderTraveler(List<TravelerVo> travelerVos, Long orderId, Long userId, Long sellerId) {
		
		orderShardingWapper.clearCache();
		
		Logger.comment("开始验证order_traveler");
		
		List<OrderTravelerPo> actualOrderTravelerList = orderShardingWapper.selectOrderTravelersbyOrderId(orderId);
		
		// 数据库的出行人顺序和下单时候的顺序一致
		for (int i = 0; i < travelerVos.size(); i++) {
			
			TravelerVo expectTravelerVo = travelerVos.get(i);
			OrderTravelerPo actualTravelerVo = actualOrderTravelerList.get(i);
			
			int index = i + 1;
			
			Logger.comment(String.format("在orderId：%s 第  %s 个旅行者名称：%s",
					orderId, index, expectTravelerVo.getTravelerName()));

			Logger.verifyEquals(orderId, actualTravelerVo.getOrderId(),
					"验证OrderId");
			Logger.verifyEquals(userId, actualTravelerVo.getUserId(),
					"验证UserId");
			Logger.verifyEquals(sellerId, actualTravelerVo.getSellerId(),
					"验证SellerId");
			Logger.verifyEquals(expectTravelerVo.getTravelerName(),
					actualTravelerVo.getTravelerName(), "验证TravelerName");
			Logger.verifyEquals(expectTravelerVo.getTravelerPhone(),
					actualTravelerVo.getTravelerPhone(), "验证TravelerPhone");
			Logger.verifyEquals(index, actualTravelerVo.getTravelerIndex(),
					"验证TravelerIndex");
			DataUtil.verifyDateEquals(expectTravelerVo.getTravelerDate(),
					actualTravelerVo.getTravelerDate(), "验证TravelerDate");
			Logger.verifyEquals(expectTravelerVo.getTravelerIdcard(),
					actualTravelerVo.getTravelerIdCard(), "验证TravelerIdCard");
			Logger.verifyEquals(expectTravelerVo.getRemark(),
					actualTravelerVo.getRemark(), "验证Remark");

			Logger.verifyEquals(true,
					Utils.calcTimeSpanMin(actualTravelerVo.getAddTime()) < 2,
					"验证数据库AddTime跟系统当前时间差为2分钟内");
			Logger.verifyEquals(
					true,
					Utils.calcTimeSpanMin(actualTravelerVo.getUpdateTime()) < 2,
					"验证数据库UpdateTime跟系统当前时间差为2分钟内");
		}
	}
	
	private MainOrder buildOrder() {

		MainOrder mainOrder = new MainOrder();

		placeOrderByApportionedAmountReq.getSalesman();

//		// 各订单分摊平台优惠券的权重
//		List<BigDecimal> orderWeightsOnYmatouCoupon = new ArrayList<BigDecimal>();
//
//		// 各订单分摊预付卡金额的权重
//		List<BigDecimal> orderWeightsPrepaid = new ArrayList<BigDecimal>();
//
//		// 各订单分摊折扣的权重
//		List<BigDecimal> orderWeightsDiscount = new ArrayList<BigDecimal>();
//
//		// 所有适用平台优惠券的商品的定金总额
//		BigDecimal totalProductPriceInYmatouCoupon = BigDecimal.ZERO;

		// 所有订单
		List<Order> allOrders = new ArrayList<Order>();
		
//		String currency = placeOrderByApportionedAmountReq.getCurrency();
		BigDecimal totalProxyProfit = BigDecimal.ZERO;

		for (OrderGroupVo groupVo : placeOrderByApportionedAmountReq.getOrderGroups()) {

			OrderGroup group = new OrderGroup();

			group.setOrderGroupVo(groupVo);
			mainOrder.getOrderGroups().add(group);

			BigDecimal totalProductPriceInSellerCoupon = BigDecimal.ZERO;
			int orderCount = 0;
			
			BigDecimal serviceRate = group.getOrderGroupVo().getServiceRate();

			for (OrderVo orderVo : groupVo.getOrders()) {

				Order order = new Order();

				order.setOrderVo(orderVo);

				order.setSellerId(groupVo.getSellerId());

				allOrders.add(order);
				
				order.setCurrency(placeOrderByApportionedAmountReq.getCurrency());
				order.setCurrencySymbol(placeOrderByApportionedAmountReq.getCurrencySymbol());

				if (null != placeOrderByApportionedAmountReq.getHunterId())
					order.setHunterId(Long.valueOf(placeOrderByApportionedAmountReq.getHunterId()));

				if (null != placeOrderByApportionedAmountReq.getHunterOrderType())
					order.setHunterOrderType(Integer.valueOf(placeOrderByApportionedAmountReq
							.getHunterOrderType()));

				BigDecimal orderFreight = BigDecimal.ZERO;
				BigDecimal orderDiscount = BigDecimal.ZERO;
				BigDecimal orderSellerPromotionAmount = BigDecimal.ZERO;
				BigDecimal orderSellerCouponAmount = BigDecimal.ZERO;
				BigDecimal orderTaxFee = BigDecimal.ZERO;

//				BigDecimal orderWeightOnYmatouCoupon = BigDecimal.ZERO;
//
//				BigDecimal orderWeightOnDiscount = BigDecimal.ZERO;
				
				orderCount = orderCount + 1;
				int orderItemCount = 0;

				for (OrderItemVo orderItemVo : orderVo.getOrderItems()) {

					OrderItem orderItem = new OrderItem();

					orderItem.setItemVo(orderItemVo);

					order.getOrderItems().add(orderItem);

					if (Utils.falseIfNull(orderItemVo.getFullReductionFreeFreight()))
						orderFreight = orderFreight.add(BigDecimal.ZERO);
					else
						orderFreight = orderFreight.add(Utils
								.zeroIfNull(orderItemVo.getFreight()));

					// 累计订单的总成交价
					BigDecimal totalProductPrice = orderItemVo
							.getProductPrice()
							.multiply(
									new BigDecimal(orderItemVo.getProductNum()));
					BigDecimal proxyPrice = null;
					
					// 如果是直销商
					if (order.getSellerId() == orderVo.getGoodsOwnerId()) {
						
						proxyPrice = BigDecimal.ZERO;
						orderItem.setServiceRate(serviceRate);
					} else {
						
						proxyPrice = SqTradingProductService
								.getProxyChainInfo(orderItemVo.getCatalogId(),
										order.getSellerId()).getFromParentPrice();
					}
					
					//获得该商品的利润
					BigDecimal productProxyProfit = orderItemVo
							.getProductPrice()
							.subtract(proxyPrice)
							.multiply(
									new BigDecimal(orderItemVo.getProductNum()));

					order.getOrderItemWeightsOnFreight().add(totalProductPrice);

					order.setTotalProductPrice(order.getTotalProductPrice()
							.add(totalProductPrice));

					if (groupVo.getSellerCoupon() != null
							&& couponApplicable(orderItemVo,
									groupVo.getSellerCoupon())) {

						order.setSellerCouponCode(groupVo.getSellerCoupon()
								.getCouponCode());

						// 订单中适用商家优惠券的成交价总额
						order.setTotalProductPriceInSellerCoupon(order
								.getTotalProductPriceInSellerCoupon().add(
										totalProductPrice));

						totalProductPriceInSellerCoupon = totalProductPriceInSellerCoupon
								.add(totalProductPrice);
						order.getOrderItemWeightsOnSellerCoupon().add(
								totalProductPrice);

					} else {
						order.getOrderItemWeightsOnSellerCoupon().add(
								BigDecimal.ZERO);
					}

//					if (placeOrderByApportionedAmountReq.getYmatouCoupon() != null) {
//						if (couponApplicable(orderItemVo,
//								placeOrderByApportionedAmountReq.getYmatouCoupon())) {
//							// 订单可以分摊平台优惠券
//							order.setYmatouCouponCode(placeOrderByApportionedAmountReq
//									.getYmatouCoupon().getCouponCode());
//
//							// 商品分摊平台优惠券的权重
//							order.getOrderItemWeightsOnYmatouCoupon().add(
//									totalProductPrice);
//
//							// 订单分摊平台优惠券的权重
//							orderWeightOnYmatouCoupon = orderWeightOnYmatouCoupon
//									.add(totalProductPrice);
//
//							totalProductPriceInYmatouCoupon = totalProductPriceInYmatouCoupon
//									.add(totalProductPrice);
//
//						} else {
//							order.getOrderItemWeightsOnYmatouCoupon().add(
//									BigDecimal.ZERO);
//						}
//					}
					
					totalProxyProfit = totalProxyProfit.add(productProxyProfit);
					
					orderItemCount = orderItemCount + 1;

//					if (placeOrderByApportionedAmountReq.getDiscount() != null) {
//
//						// 商品分摊折扣的权重按照商品价格
//						order.getOrderItemWeightsOnDiscount().add(
//								totalProductPrice);
//
//						// 订单分摊折扣的权重按照商品利润
//						orderWeightOnDiscount = orderWeightOnDiscount
//								.add(productProxyProfit);
//					}
					
					// 如果预分摊信息不为空
					if (null != orderItemVo.getOrderItemPreApportionVo()) {

						OrderItemPreApportionVo orderItemPreApportionVo = orderItemVo
								.getOrderItemPreApportionVo();

						orderItem.setDiscount(Utils
								.zeroIfNull(orderItemPreApportionVo
										.getDiscount()));
						orderItem.setSellerCouponValue(Utils
								.zeroIfNull(orderItemPreApportionVo
										.getSellerCouponAmount()));
						// orderItem.setSellerPromotion(sellerPromotion);
						orderItem.setSellerPromotionAmount(Utils
								.zeroIfNull(orderItemPreApportionVo
										.getSellerPromotionAmount()));

						orderDiscount = orderDiscount.add(orderItem
								.getDiscount());
						orderSellerPromotionAmount = orderSellerPromotionAmount
								.add(orderItem.getSellerPromotionAmount());
						orderSellerCouponAmount = orderSellerCouponAmount
								.add(orderItem.getSellerCouponValue());
						orderTaxFee = orderTaxFee.add(Utils.zeroIfNull(orderItemPreApportionVo.getTaxFee()));
					}
				} // end orderItems

//				orderWeightsPrepaid.add(order.getTotalProductPrice());

				order.setFreight(orderFreight);

				order.setGoodsOwnerId(orderVo.getGoodsOwnerId());

				order.setShenqiLogisticsType(orderVo.getShenqiLogisticsType());

				order.setShenqiIdCardRequirement(orderVo
						.getShenqiIdCardRequirement());
				
				order.setOrderDiscount(orderDiscount);
				order.setSellerPromotionAmount(orderSellerPromotionAmount);
				order.setSellerCouponValue(orderSellerCouponAmount);
				order.setTaxFee(orderTaxFee);

//				orderWeightsDiscount.add(orderWeightOnDiscount);
//
//				orderWeightsOnYmatouCoupon.add(orderWeightOnYmatouCoupon);
				group.getOrderWeightsOnSellerCoupon().add(
						order.getTotalProductPriceInSellerCoupon());

				group.getOrders().add(order);

			} // end orders

//			// 分摊商家优惠活动金额
//			apportionSellerPromotions(group, currency);
//
//			if (groupVo.getSellerCoupon() != null) {
//
//				// 分摊商家优惠券
//				if (totalProductPriceInSellerCoupon.compareTo(groupVo
//						.getSellerCoupon().getCouponValue()) <= 0) {
//					throw new IllegalArgumentException(
//							"商家适用优惠券的商品成交价总额必须大于商家优惠券总额:"
//									+ groupVo.getSellerId());
//				}
//
//				// 分摊商家优惠券到订单
//				apportionSellerCouponToOrder(group, currency);
//
//				// 分摊商家优惠券到订单项
//				apportionSellerCouponToOrderItem(group, currency);
//
//			}
		}// end groups
		
		// 分摊平台优惠券
//		if (placeOrderByApportionedAmountReq.getYmatouCoupon() != null) {
//
//			apportionYmatouCouponToOrder(allOrders, placeOrderByApportionedAmountReq
//					.getYmatouCoupon().getCouponValue(),
//					orderWeightsOnYmatouCoupon);
//			apportionYmatouCouponToOrderItem(allOrders);
//		}
//
//		// 分摊折扣
//		if (placeOrderByApportionedAmountReq.getDiscount() != null) {
//
//			// 如果总利润为0，则订单分摊折扣的权重按照商品价格
//			if (totalProxyProfit.compareTo(BigDecimal.ZERO) == 0) {
//
//				orderWeightsDiscount.clear();
//				
//				for (Order order : allOrders) 
//					orderWeightsDiscount.add(order.getTotalProductPrice());
//			}
//			
//			apportionOrderDiscountToOrder(allOrders,
//					placeOrderByApportionedAmountReq.getDiscount(), orderWeightsDiscount, currency);
//			apportionOrderDiscountToOrderItem(allOrders, currency);
//		}
		
//		calcExpectedOrderTaxFee(allOrders, placeOrderByApportionedAmountReq.getAddress());

		return mainOrder;
	}

	private static boolean couponApplicable(OrderItemVo orderItem,
			CouponVo coupon) {
		switch (coupon.getApplianceType()) {
		case ALL:
			return true;
		case SPEC_RODUCT:
			return coupon.getApplianceTargets().contains(
					orderItem.getProductId());
		default:
			throw new IllegalArgumentException("未知的优惠券适用类型:"
					+ coupon.getApplianceType());
		}
	}

//	/**
//	 * 分摊商家优惠
//	 *
//	 * @param group
//	 */
//	private static void apportionSellerPromotions(OrderGroup group, String currency) {
//		if (!CollectionUtils.isEmpty(group.getOrderGroupVo()
//				.getSellerPromotionApportions())) {
//			group.distributeSellerPromotionApportions(currency);
//		}
//	}

//	/**
//	 * 分摊商家优惠券到订单
//	 */
//	private static void apportionSellerCouponToOrder(OrderGroup g, String currency) {
//
////		BigDecimal[] result = Utils.apportionByWeightsAndMaxLimit(g
////				.getOrderGroupVo().getSellerCoupon().getCouponValue(), g
////				.getOrderWeightsOnSellerCoupon().toArray(new BigDecimal[0]), g
////				.calcMaxPromotionsLeft(), null);
//		
//		BigDecimal[] result = Utils.apportionByWeights3(g
//				.getOrderGroupVo().getSellerCoupon().getCouponValue(), g
//				.getOrderWeightsOnSellerCoupon().toArray(new BigDecimal[0]), currency);
//
//		for (int i = 0; i < result.length; i++) {
//			g.getOrders().get(i).setSellerCouponValue(result[i]);
//		}
//	}

//	/**
//	 * 分摊商家优惠券到订单商品
//	 * 
//	 * @param g
//	 */
//	private static void apportionSellerCouponToOrderItem(OrderGroup g, String currency) {
//
//		for (Order order : g.getOrders()) {
//			if (order.getSellerCouponCode() != null) {
//				BigDecimal[] result = Utils.apportionByWeights3(
//						order.getSellerCouponValue(),
//						order.getOrderItemWeightsOnSellerCoupon().toArray(
//								new BigDecimal[0]), currency);
//				for (int i = 0; i < result.length; i++) {
//					order.getOrderItems().get(i)
//							.setSellerCouponValue(result[i]);
//				}
//			}
//		}
//	}

//	/**
//	 * 分摊平台优惠券到订单
//	 * 
//	 * @param orders
//	 * @param couponValue
//	 * @param orderWeights
//	 */
//	private static void apportionYmatouCouponToOrder(List<Order> orders,
//			BigDecimal couponValue, List<BigDecimal> orderWeights) {
//
//		List<BigDecimal> maxLimits = new ArrayList<BigDecimal>();
//		for (Order o : orders) {
//			maxLimits.add(o.calcMaxPromotionLeft());
//		}
//
//		BigDecimal[] result = Utils.apportionByWeightsAndMaxLimit(couponValue,
//				orderWeights.toArray(new BigDecimal[0]),
//				maxLimits.toArray(new BigDecimal[0]), null);
//
//		for (int i = 0; i < result.length; i++) {
//			orders.get(i).setYmatouCouponValue(result[i]);
//		}
//	}

//	/**
//	 * 分摊平台优惠券到订单商品
//	 * 
//	 * @param orders
//	 */
//	private static void apportionYmatouCouponToOrderItem(List<Order> orders) {
//
//		for (Order order : orders) {
//			BigDecimal[] result = Utils.apportionByWeights3(
//					order.getYmatouCouponValue(),
//					order.getOrderItemWeightsOnYmatouCoupon().toArray(
//							new BigDecimal[0]), null);
//			for (int i = 0; i < result.length; i++) {
//				order.getOrderItems().get(i).setYmatouCouponValue(result[i]);
//			}
//		}
//	}

//	/**
//	 * 分摊平台折扣到订单
//	 * 
//	 * @param orders
//	 * @param couponValue
//	 * @param orderWeights
//	 */
//	private static void apportionOrderDiscountToOrder(List<Order> orders,
//			BigDecimal discountValue, List<BigDecimal> orderWeights, String currency) {
//
//		List<BigDecimal> maxLimits = new ArrayList<BigDecimal>();
//		for (Order o : orders) {
//			maxLimits.add(o.calcMaxPromotionLeftAndFreight());
//		}
//
//		BigDecimal[] result = Utils.apportionByWeightsAndMaxLimit(
//				discountValue, orderWeights.toArray(new BigDecimal[0]),
//				maxLimits.toArray(new BigDecimal[0]), currency);
//
//		for (int i = 0; i < result.length; i++) {
//			orders.get(i).setOrderDiscount(result[i]);
//		}
//	}
	
//	private static void calcExpectedOrderTaxFee(List<Order> orders, String address) {
//		
//		int scale = 0;
//		
//		for (Order o : orders) {
//
//			BigDecimal orderTaxFee = BigDecimal.ZERO;
//			BigDecimal productTaxFee = BigDecimal.ZERO;
//
//			for (OrderItem orderItem : o.getOrderItems()) {
//				
//				if (TradingForDGSQCallService.isFreePerimeters(placeOrderByApportionedAmountReq.getAddress()))
//					productTaxFee = BigDecimal.ZERO;
//				else {
//					
//					if (null == placeOrderByApportionedAmountReq.getCurrency()) 
//						scale = 2;
//					else if (null != placeOrderByApportionedAmountReq.getCurrency() && placeOrderByApportionedAmountReq.getCurrency().equalsIgnoreCase("JPY"))
//						scale = 0;
//					
//					boolean fullReductionFreeFreight = Utils.falseIfNull(orderItem.getItemVo().getFullReductionFreeFreight());
//					
//					productTaxFee = Utils
//							.zeroIfNull(fullReductionFreeFreight ? BigDecimal.ZERO : orderItem.getItemVo().getFreight())
//							.divide(new BigDecimal(orderItem.getItemVo()
//									.getProductNum()), 32, RoundingMode.DOWN)
//							.add(orderItem.getItemVo().getProductPrice())
//							.add(Utils.zeroIfNull(orderItem.getDiscount()).divide(
//									new BigDecimal(orderItem.getItemVo()
//											.getProductNum()), 32,
//									RoundingMode.DOWN))
//							.subtract(
//									Utils.zeroIfNull(
//											orderItem.getSellerCouponValue())
//											.divide(new BigDecimal(orderItem
//													.getItemVo().getProductNum()),
//													32, RoundingMode.DOWN))
//							.subtract(
//									Utils.zeroIfNull(orderItem
//											.getYmatouCouponValue()))
//							.subtract(
//									Utils.zeroIfNull(orderItem.getSellerPromotionAmount())
//											.divide(new BigDecimal(orderItem
//													.getItemVo().getProductNum()),
//													32, RoundingMode.DOWN))
//							.subtract(
//									Utils.zeroIfNull(orderItem.getItemVo()
//											.getYmtPromotionAmount()))
//							.multiply(
//									Utils.zeroIfNull(orderItem.getItemVo()
//											.getProdTaxRate()))
//							.setScale(scale, RoundingMode.HALF_UP);
//						
//						orderTaxFee = orderTaxFee.add(productTaxFee.multiply(new BigDecimal(orderItem.getItemVo()
//										.getProductNum())));
//				}
//			}
//			
//			o.setTaxFee(orderTaxFee);
//		}
//	}

//	/**
//	 * 分摊折扣到订单商品
//	 * 
//	 * @param orders
//	 */
//	private static void apportionOrderDiscountToOrderItem(List<Order> orders, String currency) {
//
//		for (Order order : orders) {
//			BigDecimal[] result = Utils.apportionByWeights3(order
//					.getOrderDiscount(), order.getOrderItemWeightsOnDiscount()
//					.toArray(new BigDecimal[0]), currency);
//			for (int i = 0; i < result.length; i++) {
//				order.getOrderItems().get(i).setDiscount(result[i]);
//			}
//		}
//	}
	
//	private static BigDecimal calActualOrderTaxFee(List<OrderDetailPo> orderDetails) {
//		
//		BigDecimal taxFee = BigDecimal.ZERO;
//		
//		for (OrderDetailPo detailPo : orderDetails) {
//			
//			taxFee = taxFee.add(detailPo.getTaxFee().multiply(
//					new BigDecimal(detailPo.getProductCount())));
//		}
//		
//		return taxFee;
//	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_001() {
		Logger.start(true, "渠道商一次下单一个商品,生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_002() {
		Logger.start(true, "goodOwnerId与代理链不一致，下单失败");
		try {

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, 3383);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(198, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"goodOwnerId mismatch in proxy chain"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_003() {
		Logger.start(true, "shopOwnerId与代理链不一致，下单失败");
		try {

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			productBean.setSellerId(500058147L);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(198, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"shopOwnerId mismatch in proxy chain"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_004() {
		Logger.start(true, "商品的成交价小于代理价， 下单失败");
		try {

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);

			// 修改商品的成交价格
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setProductPrice(BigDecimal.ONE);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(198, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(true,
					placeOrderByApportionedAmountCall.getMsg().contains("商品的成交价小于代理价"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_005() {
		Logger.start(true, "一次下单多个商品,生成一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			
			orderItemVo.setProductPrice(new BigDecimal(productBean
					.getAgentCatalogPriceList().get(1).getAgentPrice()));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);
					
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);

			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_007() {
		Logger.start(true, "同一个订单，不同的代理链，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			AgentProductBean productBean2 = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0);
			OrderItemVo orderItemVo = SqTradingCallService
					.createOrderItemVo(productBean2.getProductId(),
							productBean2.getCatalogList().get(0));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);

			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(198, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"shopOwnerId mismatch in proxy chain"),
					"校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_008() {
		Logger.start(true, "一次下单多个商品,生产两个订单，同一个买手");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean.getProductId());
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(autotest_goodsOwnerId);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(1).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_009() {
		Logger.start(true, "一次下单多个商品,生产两个订单，同一个买手使用折扣上调");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean.getProductId());
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(autotest_goodsOwnerId);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);

			placeOrderReq.setDiscount(new BigDecimal("10.00"));
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(new BigDecimal("3.99"));
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(1).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("6.01"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_010() {
		Logger.start(true, "一次下单多个商品,生产两个订单，同一个买手使用折扣下调");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			int csId = SqTradingCallService.bindClientService(
					productBean.getSellerId(), 1);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(csId, BigDecimal.ZERO,
							20238699, productBean, autotest_goodsOwnerId);

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean.getProductId());
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(autotest_goodsOwnerId);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);

			placeOrderReq.setDiscount(new BigDecimal("-10.00"));

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(new BigDecimal("-3.99"));
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(1).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("-6.01"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_011() {
		Logger.start(true, "一次下单多个买手，下单报错");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			int secondGoodsOwnerId = 500042327;
			AgentProductBean productBean2 = DGSQBuildProxyChainCallService
					.createProxychain(secondGoodsOwnerId, 1, false);
			OrderGroupVo orderGroupVo = SqTradingCallService
					.createOrderGroupVo(productBean2, secondGoodsOwnerId);

			placeOrderReq.getOrderGroups().add(orderGroupVo);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(new BigDecimal("-3.99"));
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(1).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("-6.01"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(true,
					placeOrderByApportionedAmountCall.getMsg().contains("不能有来自多个店铺的订单"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_012() {
		Logger.start(true, "代购神器直销商，带有买手优惠券，带有买手优惠，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId(), true);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0).setSellerPromotionApportions(sellerPromotionList);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(new BigDecimal("-3.99"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("14.99"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("9.98"));
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("-6.01"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("0.01"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("0.02"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_013() {
		Logger.start(true, "代理商一次下单一个商品,生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_014() {
		Logger.start(true, "代购神器直销商，下单时上调折扣，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId());

			placeOrderReq.setDiscount(BigDecimal.TEN);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.TEN);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_015() {
		Logger.start(true, "代购神器渠道商，下单时下调折扣等于直销商利润，下单报错");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			BigDecimal discount = item.getProductPrice()
					.multiply(new BigDecimal(item.getProductNum()))
					.add(item.getFreight());

			placeOrderReq.setDiscount(discount.negate());

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(placeOrderReq.getDiscount());
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(true, placeOrderByApportionedAmountCall.getMsg()
					.contains("订单成交价总额必须大于分摊到的平台优惠券/商家优惠券/商家营销活动优惠/预付卡金额之和"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_016() {
		Logger.start(true, "代购神器，下单时传入proxyOrderId，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			placeOrderReq.setProxyOrderId(1234);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(placeOrderReq.getDiscount());
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_017() {
		Logger.start(true, "渠道商一次下单一个商品，下单币种为CNY,生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			placeOrderReq.setCurrency("CNY");

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_018() {
		Logger.start(true, "渠道商一次下单一个商品，下单币种为外币,生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			placeOrderReq.setCurrency(productBean.getCurrency());

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_019() {
		Logger.start(true, "外币币种类型不正确，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			placeOrderReq.setCurrency("CHN");

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(198, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"currency is error"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_020() {
		Logger.start(true, "一次下单多个商品,下单币种为外币，生产两个订单，同一个买手使用折扣下调");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false, true);
			String currency = productBean.getCurrency();

			int csId = SqTradingCallService.bindClientService(
					productBean.getSellerId(), 1);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(csId, BigDecimal.ZERO,
							20238699, productBean, autotest_goodsOwnerId);

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean.getProductId());
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(autotest_goodsOwnerId);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);

			placeOrderReq.setDiscount(new BigDecimal("-10.00"));
			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(new BigDecimal("-4.00"));
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(1).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("-6.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_021() {
		Logger.start(true, "代购神器渠道商，下单时下调折扣等于直销商利润，使用外币，下单报错");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false, true);
			String currency = productBean.getCurrency();

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			BigDecimal discount = item.getProductPrice()
					.multiply(new BigDecimal(item.getProductNum()))
					.add(item.getFreight());

			placeOrderReq.setDiscount(discount.negate());
			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);

			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(placeOrderReq.getDiscount());
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(true, placeOrderByApportionedAmountCall.getMsg()
					.contains("订单成交价总额必须大于分摊到的平台优惠券/商家优惠券/商家营销活动优惠/预付卡金额之和"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_022() {
		Logger.start(true, "一次下单多个商品,使用外币，生成一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false, true);
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderItemVo orderItemVo = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);
			
			placeOrderReq.setDiscount(new BigDecimal("10.00"));
			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_023() {
		Logger.start(true, "一次下单多个商品,生产两个订单，一单为外币，另一单为CNY，同一个买手，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false, true);
			
			AgentProductBean productBean1 = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean1));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean1.getProductId());
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean1.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(autotest_goodsOwnerId);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			placeOrderReq.setCurrency(currency);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(1).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(198, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(true, placeOrderByApportionedAmountCall.getMsg()
					.contains("Failed to fetch proxy chain"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_024() {
		Logger.start(true, "一次下单多个商品,生产两个订单，外币为日币，商品的价格带有小数，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 1, false, true);
			
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, 500058147);
			placeOrderReq.setCurrency(currency);

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean.getProductId());
			orderVo.getOrderItems().get(0).setProductPrice(new BigDecimal("433.11"));
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(500058147L);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(1).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals("商品运费或价格不能含有小数", placeOrderByApportionedAmountCall.getMsg(), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_025() {
		Logger.start(true, "一次下单多个商品,生产两个订单，外币为日币，设置的折扣有小数，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 1, false, true);
			
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, 500058147);

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean.getProductId());
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(500058147L);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			placeOrderReq.setCurrency(currency);
			placeOrderReq.setDiscount(new BigDecimal("10.01"));

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(1).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.01"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals("调价金额不能含有小数", placeOrderByApportionedAmountCall.getMsg(), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_026() {
		Logger.start(true, "一次下单多个商品,生产两个订单，外币为日币，分摊的折扣金额有小数，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 1, false, true);
			
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, 500058147);
			
			//创建一个新的order
			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean.getProductId());
			orderVo.getOrderItems().get(0)
					.setProductPrice(new BigDecimal("2000"));
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(500058147L);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			placeOrderReq.setCurrency(currency);
			placeOrderReq.setDiscount(new BigDecimal("10.00"));

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(new BigDecimal("0.99"));
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(1).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.01"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals("调价金额不能含有小数", placeOrderByApportionedAmountCall.getMsg(), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_027() {
		Logger.start(true, "一次下单多个商品,生产一个订单，外币为日币，分摊的折扣金额包含小数，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 1, false, true);
			
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, 500058147);

			//创建一个新的orderItem，并隶属于第一个订单
			OrderItemVo orderItem = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItem.setProductPrice(new BigDecimal("2000"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItem);

			placeOrderReq.setCurrency(currency);
			placeOrderReq.setDiscount(new BigDecimal("10.00"));

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.01"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals("调价金额不能含有小数", placeOrderByApportionedAmountCall.getMsg(), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_028() {
		Logger.start(true, "一次下单多个商品,使用韩币，生成一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createKRProxychain(500072235, 1, false);
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, 500072235);

			OrderItemVo orderItemVo = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1)); 

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);
			
			placeOrderReq.setDiscount(new BigDecimal("10.00"));
			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_029() {
		Logger.start(true, "渠道商一次下单一个商品,生产一个订单,带有税率和限购");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo.setProdTaxRate(new BigDecimal("0.125432"));
			orderItemVo.setBuyDailyLimit(true);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			orderItemVo = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_030() {
		Logger.start(true, "一次下单多个商品,使用日币，生成一个订单, 每个商品都有税率和限购");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 0, false, true);
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, 500058147);
			
			placeOrderReq.getOrderGroups().get(0).setServiceRate(new BigDecimal("0.16"));
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo1.setProdTaxRate(new BigDecimal("0.067829"));
			orderItemVo1.setBuyDailyLimit(false);

			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1)); 
			
			orderItemVo2.setProdTaxRate(new BigDecimal("0.124521"));
			orderItemVo2.setBuyDailyLimit(true);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);

			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_031() {
		Logger.start(true, "渠道商一次下单多个商品,带有折扣，生产一个订单,带有税率和限购");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo1.setProdTaxRate(new BigDecimal("0.091"));
			orderItemVo1.setBuyDailyLimit(true);
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1)); 
			
			orderItemVo2.setProdTaxRate(new BigDecimal("0.23059"));
			orderItemVo2.setBuyDailyLimit(false);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			placeOrderReq.setDiscount(BigDecimal.TEN);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_032() {
		Logger.start(true, "渠道商一次下单多个商品,带有折扣，生成两个订单,带有税率和限购");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo1.setProdTaxRate(new BigDecimal("0.12"));
			orderItemVo1.setBuyDailyLimit(true);
			
			//创建第二个商品
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1)); 
			
			orderItemVo2.setProdTaxRate(new BigDecimal("0.12"));
			orderItemVo2.setBuyDailyLimit(false);
			
			//创建第二个订单
			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists.newArrayList(productBean));
			
			orderItemVo2 = orderVo.getOrderItems().get(0);
			
			orderItemVo2.setCatalogId(productBean.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.10"));
			orderItemVo2.setBuyDailyLimit(false);

			orderVo.setGoodsOwnerId(autotest_goodsOwnerId);
			orderVo.setShenqiLogisticsType(999);
			orderVo.setShenqiIdCardRequirement(0);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			
			placeOrderReq.setDiscount(BigDecimal.TEN.negate());

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE.negate());
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00").negate());
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_035() {
		Logger.start(true, "代购神器日本直销商，带有买手优惠券，带有买手优惠，下单成功");
		try {
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 1, false, true);
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId(), true);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setProductPrice(new BigDecimal("1.00"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0).setSellerPromotionApportions(sellerPromotionList);
			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("4.00"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("12.00"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("6.00"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("3.00"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_036() {
		Logger.start(true, "代购神器继承代理，售价利润小于优惠金额，下单成功");
		try {
			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createInheritedProxychain((int) mchId, false);
			
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, (int) mchId, true);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setProductPrice(new BigDecimal(13));
			orderItemVo1.setFreight(BigDecimal.ZERO);
			orderItemVo1.setProductNum(1);
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));
			orderItemVo2.setProductPrice(new BigDecimal(12));
			orderItemVo1.setFreight(BigDecimal.ZERO);
			orderItemVo2.setProductNum(1);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0)
					.setSellerPromotionApportions(sellerPromotionList);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("4.00"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("12.00"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("6.00"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("3.00"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_038() {
		Logger.start(true, "代购神器继承代理，使用订单折扣，下单失败");
		try {
			
			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createInheritedProxychain((int) mchId, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, new BigDecimal("1.00"), 20238699,
							productBean, (int) mchId, false);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setProductPrice(new BigDecimal(13));
			orderItemVo1.setFreight(BigDecimal.ZERO);
			orderItemVo1.setProductNum(1);
			
			OrderVo orderVo2 = SqTradingCallService.createOrderVo(Arrays.asList(productBean));
			
			OrderItemVo orderItemVo2 = orderVo2.getOrderItems().get(0);
			
			orderItemVo2.setCatalogId(productBean.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));
			orderItemVo2.setProductPrice(new BigDecimal(12));
			orderItemVo1.setFreight(BigDecimal.ZERO);
			orderItemVo2.setProductNum(1);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"您是分销小店无法改价，请联系渠道商！"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_039() {
		Logger.start(true, "代购神器日本直销商，带有买手优惠券，支持线下支付，下单成功");
		try {
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 1, false, true);
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId(), true);
			
			placeOrderReq.setSupportOfflinePay(true);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setProductPrice(new BigDecimal("1.00"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setSellerCouponAmount(BigDecimal.ONE);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("9.00"));
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_040() {
		Logger.start(true, "代购神器日本直销商，带有买手优惠券，不支持线下支付，下单成功");
		try {
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 1, false, true);
			String currency = productBean.getCurrency();
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId(), true);
			
			placeOrderReq.setSupportOfflinePay(false);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setProductPrice(new BigDecimal("1.00"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			placeOrderReq.setCurrency(currency);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setSellerCouponAmount(BigDecimal.ONE);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("9.00"));
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_041() {
		Logger.start(true, "渠道商一次下单一个虚拟库存商品,生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			// 实际库存10 + 虚拟库存2
			orderItemVo.setProductNum(12);
			orderItemVo.setVirtualProductNum(2);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();
			
			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_042() {
		Logger.start(true, "直销商一次下单一个虚拟库存商品,生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			// 实际库存12 + 虚拟库存2
			orderItemVo.setProductNum(12);
			orderItemVo.setVirtualProductNum(2);
			
			orderItemVo.setProductPrice(BigDecimal.TEN);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();
			
			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_043() {
		Logger.start(true, "直销商一次下单一个虚拟库存商品,虚拟库存不足，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			// 实际库存130 + 虚拟库存30
			orderItemVo.setProductNum(131);
			orderItemVo.setVirtualProductNum(31);
			
			orderItemVo.setProductPrice(BigDecimal.TEN);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();
			
			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(108, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(true, placeOrderByApportionedAmountCall.getMsg()
					.contains("商品库存不足|商品库存不足"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_PlaceOrderByApportionedAmount_044() {
		Logger.start(true, "虚拟库存商品下单,扣库存返回未知异常,下单失败,发送返库存消息");
		try {

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			// 实际库存130 + 虚拟库存30
			orderItemVo.setProductNum(131);
			orderItemVo.setVirtualProductNum(31);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(105, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals("扣库存失败", placeOrderByApportionedAmountCall.getMsg(), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

			MainOrderPo actualMainOrder = orderShardingWapper
					.selectMianOrderbyId(placeOrderReq.getMainOrderId());

			Logger.verifyEquals(
					ReduceProdStocksStatusEnum.SENT_RTN_MSG.getCode(),
					actualMainOrder.getStockStatus(), "验证数据库StockStatus");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_045() {
		Logger.start(true, "渠道商一次下单多个虚拟库存商品,生产多个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO,
							20238699, productBean, (int) autotest_goodsOwnerId);

			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			// 实际库存10 + 虚拟库存2
			orderItemVo1.setProductNum(12);
			orderItemVo1.setVirtualProductNum(2);

			// 第二个订单
			OrderVo orderVo = SqTradingCallService.createOrderVo(Arrays
					.asList(productBean));
			
			OrderItemVo orderItemVo2 = orderVo.getOrderItems().get(0);

			orderItemVo2.setProductNum(1);
			orderItemVo2.setVirtualProductNum(1);
			
			orderVo.setGoodsOwnerId(autotest_goodsOwnerId);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);

			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();
			
			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_046() {
		Logger.start(true, "渠道商一次下单一个商品,生产一个神器代理购买订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.setShenqiProxyBuyOrder(true);
			placeOrderReq.setShenqiBuyOrderCsId(1235678L);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);

			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_047() {
		Logger.start(true, "一次下单多个商品,生成一个神器代理购买订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderItemVo orderItemVo = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);
			
			placeOrderReq.setDiscount(new BigDecimal("10.00"));
			placeOrderReq.setShenqiProxyBuyOrder(true);
			placeOrderReq.setShenqiBuyOrderCsId(1235678L);

			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);

			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_048() {
		Logger.start(true, "一次下单多个商品,其中一个商品数×总金额大于等于20w，则下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderItemVo orderItemVo = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			
			orderItemVo.setProductPrice(new BigDecimal("2001"));
			orderItemVo.setProductNum(10);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);
			
			placeOrderReq.setDiscount(new BigDecimal("10.00"));
			placeOrderReq.setShenqiProxyBuyOrder(true);
			placeOrderReq.setShenqiBuyOrderCsId(1235678L);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(1);

			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(118, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"亲爱的，交易异常~请联系商家吧~"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_049() {
		Logger.start(true, "渠道商一次下单一个商品,商品单价为100，商品数×总金额大于等于10w，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo.setProductPrice(new BigDecimal("100"));
			orderItemVo.setProductNum(32);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(118, placeOrderByApportionedAmountCall.getErrorCodeValue(), "校验errorCodeValue");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"亲爱的，交易异常~请联系商家吧~"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_050() {
		Logger.start(true, "渠道商一次下单一个商品,商品单价为1000，商品数×总金额大于等于10w，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo.setProductPrice(new BigDecimal("1000"));
			orderItemVo.setProductNum(11);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(118, placeOrderByApportionedAmountCall.getErrorCodeValue(), "校验errorCodeValue");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"亲爱的，交易异常~请联系商家吧~"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_051() {
		Logger.start(true, "渠道商一次下单一个商品,商品单价为20000，商品数×总金额大于等于5w，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo.setProductPrice(new BigDecimal("20000"));
			orderItemVo.setProductNum(3);
			
			orderItemVo.setFreight(BigDecimal.ZERO);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(118, placeOrderByApportionedAmountCall.getErrorCodeValue(), "校验errorCodeValue");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"亲爱的，交易异常~请联系商家吧~"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_052() {
		Logger.start(true, "渠道商一次下单一个商品,商品单价为10000，商品数×总金额大于等于5w，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo.setProductPrice(new BigDecimal("10000"));
			orderItemVo.setProductNum(6);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(118, placeOrderByApportionedAmountCall.getErrorCodeValue(), "校验errorCodeValue");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"亲爱的，交易异常~请联系商家吧~"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_053() {
		Logger.start(true, "渠道商一次下单一个商品,外币标价商品，商品数×总金额大于等于5w，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.setCurrency(productBean.getCurrency());
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo.setProductPrice(new BigDecimal("10000"));
			orderItemVo.setProductNum(3);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_054() {
		Logger.start(true, "盛付通用户一次下单一个商品,商品单价为1000，商品数×总金额大于等于10w，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createShengPayProxychain(500381009, 1);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, 500381009);
			
			placeOrderReq.setPayChannelType(2);
			placeOrderReq.setCurrency(productBean.getCurrency());
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo.setProductPrice(new BigDecimal("1000"));
			orderItemVo.setProductNum(10);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_055() {
		Logger.start(true, "一次下单多个商品,代理商设置其中一个满减免运费，生产一个订单");
		try {

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);

			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			
			orderItemVo2.setProductNum(1);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			orderItemVo1.setFullReductionFreeFreight(true);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.ONE);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_056() {
		Logger.start(true, "神器代理 下单一个商品,商品单价为10000，商品数×总金额大于等于5w，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			placeOrderReq.setShenqiProxyBuyOrder(true);
			placeOrderReq.setShenqiBuyOrderCsId(54632L);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			orderItemVo.setProductPrice(new BigDecimal("10000"));
			orderItemVo.setProductNum(6);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(201, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(118, placeOrderByApportionedAmountCall.getErrorCodeValue(), "校验errorCodeValue");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"亲爱的，交易异常~请联系商家吧~"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_057() {
		Logger.start(true, "渠道商一次下单一个商品,自定义人民币结算，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			placeOrderReq.setCustomSettlementCurrencyType(1);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getErrorCodeValue(), "校验errorCodeValue");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"代理订单不能自定义结算账户"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_PlaceOrderByApportionedAmount_058() {
		Logger.start(true, "非开通双支付账户直销商一次下单一个商品,自定义外币结算，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int)autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId());
			placeOrderReq.setCustomSettlementCurrencyType(1);

			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getErrorCodeValue(), "校验errorCodeValue");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"渠道商未开通双支付账户"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_059() {
		Logger.start(true, "开通双支付账户直销商一次下单一个商品,自定义外币结算，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, 500583265);
			placeOrderReq.setCustomSettlementCurrencyType(2);

			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_060() {
		Logger.start(true, "一次下单多个商品,生产两个个订单，使用别名");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0).setOrderAlias("order1");

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean.getProductId());
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean.getCatalogList().get(1));

			orderVo.setGoodsOwnerId(autotest_goodsOwnerId);
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);
			orderVo.setOrderAlias("order2");

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);

			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(1).getOrderItems().get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_061() {
		Logger.start(true, "一次下单两个不同货头的商品,生产两个订单，同一个买手");
		try {
			
			// 美元货头
			AgentProductBean supplierProductBean_1 = DGSQBuildProxyChainCallService
					.createGoodsOwnerProduct(autotest_goodsOwnerId, "CNY", false);

			AgentProductBean productBean_1 = DGSQBuildProxyChainCallService
					.createChannel(supplierProductBean_1.getSellerId(),
							supplierProductBean_1.getProductId(), "HKG");
			
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean_1, autotest_goodsOwnerId);

			AgentProductBean supplierProductBean_2 = DGSQBuildProxyChainCallService
					.createGoodsOwnerProduct(500058147L, "CNY", false);

			AgentProductBean productBean_2 = DGSQBuildProxyChainCallService
					.createChannel(supplierProductBean_2.getSellerId(),
							supplierProductBean_2.getProductId(),
							productBean_1.getCurrency(),
							productBean_1.getSellerId());	

			OrderVo orderVo = SqTradingCallService.createOrderVo(Lists
					.newArrayList(productBean_2));

			orderVo.getOrderItems().get(0)
					.setProductId(productBean_2.getProductId());
			orderVo.getOrderItems().get(0)
					.setCatalogId(productBean_2.getCatalogList().get(0));

			orderVo.setGoodsOwnerId(supplierProductBean_2.getSellerId());
			orderVo.setShenqiLogisticsType(100);
			orderVo.setShenqiIdCardRequirement(0);

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);

			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(1).getOrderItems().get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_063() {
		Logger.start(true, "代购神器渠道商，负利润，带有买手优惠，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321L, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId, false);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			BigDecimal discount1 = orderItemVo1.getProductPrice()
					.multiply(new BigDecimal(orderItemVo1.getProductNum()));
			
			BigDecimal discount2 = orderItemVo2.getProductPrice()
					.multiply(new BigDecimal(orderItemVo2.getProductNum()));
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(discount1.add(discount2));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0)
					.setSellerPromotionApportions(sellerPromotionList);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setSellerPromotionAmount(discount1);
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setSellerPromotionAmount(discount2);
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_064() {
		Logger.start(true, "渠道商一次下单一个商品,payChannelType = 1, 境内商品，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.setPayChannelType(1);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setDomesticProduct(true);
			
			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_065() {
		Logger.start(true, "渠道商一次下单一个商品,payChannelType = 2, 多个商品，一个境内，一个境外，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.setPayChannelType(2);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setDomesticProduct(true);
			
			OrderItemVo orderItemVo = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			
			orderItemVo.setDomesticProduct(false);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_066() {
		Logger.start(true, "渠道商一次下单一个商品,带有自提信息，无需上传身份证生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.setAddressId(null);
			placeOrderReq.setAddress(null);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.setShenqiIdCardRequirement(1);
			
			placeOrderReq.setPickupInStores(true);
			PickInStoreVo pickInStoreVo = new PickInStoreVo();

			pickInStoreVo.setPickupStoreId((long) TestDataManager
					.getRandomIntNum(6));
			pickInStoreVo.setPickupType(0);
			pickInStoreVo.setPickupUserName(TestDataManager.getChineseName());
			pickInStoreVo.setPickupUserPhone(TestDataManager.getPhoneNum());
			pickInStoreVo.setUserReserveTimeSpanStart(YMTDateUtil
					.getBeforeOrNextDate(0));
			pickInStoreVo.setUserReserveTimeSpanEnd(YMTDateUtil
					.getBeforeOrNextDate(10));

			placeOrderReq.setPickInStoreVo(pickInStoreVo);

			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_067() {
		Logger.start(true, "渠道商一次下单一个商品,带有自提信息，自提为false，需上传身份证，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0).setShenqiIdCardRequirement(1);
			
			placeOrderReq.setPickupInStores(false);
			PickInStoreVo pickInStoreVo = new PickInStoreVo();

			pickInStoreVo.setPickupStoreId((long) TestDataManager
					.getRandomIntNum(6));
			pickInStoreVo.setPickupType(0);
			pickInStoreVo.setPickupUserName(TestDataManager.getChineseName());
			pickInStoreVo.setPickupUserPhone(TestDataManager.getPhoneNum());
			pickInStoreVo.setUserReserveTimeSpanStart(YMTDateUtil
					.getBeforeOrNextDate(0));
			pickInStoreVo.setUserReserveTimeSpanEnd(YMTDateUtil
					.getBeforeOrNextDate(10));

			placeOrderReq.setPickInStoreVo(pickInStoreVo);

			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_068() {
		Logger.start(true, "渠道商一次下单一个商品,下单输入PurchaserIdcardId，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.setPurchaserIdcardId(1234L);
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0).setShenqiIdCardRequirement(1);

			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_069() {
		Logger.start(true, "代购神器渠道商，下单时单个商品，0利润，向下调价，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			item.setProductPrice(new BigDecimal(productBean
					.getAgentCatalogPriceList().get(0).getAgentPrice()));
			BigDecimal discount = BigDecimal.ONE.negate();

			placeOrderReq.setDiscount(discount);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(discount);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();
			
			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_070() {
		Logger.start(true, "代购神器渠道商，下单时多个商品，0利润，向上调价，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			OrderVo orderVo = placeOrderReq.getOrderGroups().get(0).getOrders()
					.get(0);
			
			// 第一个商品利润设置为0
			OrderItemVo item1 = orderVo.getOrderItems().get(0);
			item1.setProductPrice(new BigDecimal(productBean
					.getAgentCatalogPriceList().get(0).getAgentPrice()));
			
			// 第二个商品利润设置为0
			OrderItemVo item2 = SqTradingCallService.createOrderItemVo(
					productBean.getProductId(), productBean.getCatalogList()
							.get(1));
			item2.setProductPrice(new BigDecimal(productBean
					.getAgentCatalogPriceList().get(1).getAgentPrice()));

			// 添加第二个商品
			orderVo.getOrderItems().add(item2);
			
			BigDecimal discount = BigDecimal.ONE;

			placeOrderReq.setDiscount(discount);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(discount);
			
			item1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			item2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_071() {
		Logger.start(true, "代购神器渠道商，下单时多个商品，其中一个商品0利润，向上调价，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);
			
			OrderVo orderVo = placeOrderReq.getOrderGroups().get(0).getOrders()
					.get(0);

			// 第一个商品利润设置为0
			OrderItemVo item1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			item1.setProductPrice(new BigDecimal(productBean
					.getAgentCatalogPriceList().get(0).getAgentPrice()));
			
			// 添加第二个商品
			OrderItemVo item2 = SqTradingCallService.createOrderItemVo(
					productBean.getProductId(), productBean.getCatalogList()
							.get(1));
			
			orderVo.getOrderItems().add(item2);

			BigDecimal discount = BigDecimal.ONE;

			placeOrderReq.setDiscount(discount);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(discount);
			
			item1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			item2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_072() {
		Logger.start(true, "代购神器渠道商，下单时多个订单，其中一个订单0利润，向上调价，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, autotest_goodsOwnerId);

			// 第一个商品利润设置为0
			OrderItemVo item1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			item1.setProductPrice(new BigDecimal(productBean
					.getAgentCatalogPriceList().get(0).getAgentPrice()));
			
			// 创建第二个订单
			OrderVo orderVo = SqTradingCallService.createOrderVo(Arrays
					.asList(productBean));
			orderVo.getOrderItems().remove(0);

			OrderItemVo item2 = SqTradingCallService.createOrderItemVo(
					productBean.getProductId(), productBean.getCatalogList()
							.get(1));

			// 添加商品
			orderVo.getOrderItems().add(item2);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);

			BigDecimal discount = BigDecimal.ONE;

			placeOrderReq.setDiscount(discount);

			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(discount);
			
			item1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			item2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_073() {
		Logger.start(true, "渠道商一次下单一个商品,带有WarehouseId，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.setWarehouseId(214123);
			
			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_075() {
		Logger.start(true, "渠道商一次下单一个商品,如果地址开头为香港，则免税费，生产一个订单");
		try {

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO,
							20238699, productBean, (int) autotest_goodsOwnerId);

			placeOrderReq.setAddress("海外" + TestDataManager.randomStr(5));
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0)
					.setProdTaxRate(new BigDecimal("0.17"));

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.ZERO);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_076() {
		Logger.start(true, "分销小店一次下单一个商品，生产一个订单");
		try {

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createRetailShopProxychain(mchId, BigDecimal.TEN, false);

			DGSQBaseService.editRetailShopProductRebate(
					productBean.getProductId(), productBean.getSellerId(),
					(long)mchId, new BigDecimal("15.00"));

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO,
							20238699, productBean, mchId);

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_077() {
		Logger.start(true, "分销小店一次下单多个商品，带买手优惠券和买手优惠，生产一个订单");
		try {

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createRetailShopProxychain(mchId, BigDecimal.TEN, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, mchId, true);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0).setSellerPromotionApportions(sellerPromotionList);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("4.93"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("11.93"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("5.07"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("3.07"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_078() {
		Logger.start(true, "分销小店一次下单一个商品，多级代理，生产一个订单");
		try {

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain(mchId, 4, true, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO,
							20238699, productBean, mchId);

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
//			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_079() {
		Logger.start(true, "分销小店一次下单多个商品，多级代理，带买手优惠券、买手优惠和满减优惠，生产一个订单");
		try {

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain(mchId, 3, true, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO,
							20238699, productBean, mchId, true, false);

			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setFullReductionFreeFreight(true);
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0).setSellerPromotionApportions(sellerPromotionList);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("4.93"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("11.93"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("5.07"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("3.07"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_080() {
		Logger.start(true, "渠道商一次下单一个商品，带有积分会员信息,生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.setEntryIdType(1);
			placeOrderReq.setEntryIdNo(TestDataManager.randomStr(8));
			placeOrderReq.setEntryTime(YMTDateUtil.getBeforeOrNextDate(YMTDateUtil.getDate(), 1));
			placeOrderReq.setEntryPort("entryPPPPP");
			placeOrderReq.setTransportation("autotest_flight");

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_081() {
		Logger.start(true, "渠道商一次下单一个虚拟库存商品，一个没有虚拟库存商品,生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			// 实际库存12 + 虚拟库存2
			orderItemVo1.setProductNum(12);
			orderItemVo1.setVirtualProductNum(2);
			
			orderItemVo1.setProductPrice(BigDecimal.TEN);
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			
			orderItemVo2.setProductNum(2);
			
			orderItemVo2.setProductPrice(BigDecimal.TEN);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0).getOrderItems().add(orderItemVo2);

			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();
			
			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_082() {
		Logger.start(true, "分销小店一次下单多个商品，多级代理，带买手优惠券、买手优惠和满减优惠，生产一个订单");
		try {

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain(mchId, 3, true, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO,
							20238699, productBean, mchId, true, false);

			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setFullReductionFreeFreight(true);
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0).setSellerPromotionApportions(sellerPromotionList);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("4.93"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("11.93"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("5.07"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("3.07"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_083() {
		Logger.start(true, "直销商一次下单一个商品,设置服务费率，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.getOrderGroups().get(0).setServiceRate(new BigDecimal("13.00"));

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_084() {
		Logger.start(true, "直销商一次下单多个商品,带有各种优惠和税率，设置服务费率，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.TEN,
							20238699, productBean, autotest_goodsOwnerId, true, false);
			
			OrderGroupVo orderGroupVo = placeOrderReq.getOrderGroups().get(0);

			OrderItemVo orderItemVo1 = orderGroupVo.getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setFullReductionFreeFreight(true);
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			orderGroupVo.setSellerPromotionApportions(sellerPromotionList);
			orderGroupVo.setServiceRate(new BigDecimal("12.00"));
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("4.93"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("11.93"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("5.07"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("3.07"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();	

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_085() {
		Logger.start(true, "代理商一次下单一个商品,设置服务费率，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.getOrderGroups().get(0).setServiceRate(new BigDecimal("13.00"));

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_086() {
		Logger.start(true, "校验折扣分摊是否使用apportionByWeightsAndMaxLimit，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0)
					.setProductPrice(new BigDecimal("0.01"));
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0)
					.setFreight(BigDecimal.ZERO);
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setProductNum(1);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
			.getOrderItems().get(0).setOrderItemPreApportionVo(new OrderItemPreApportionVo());
			
			AgentProductBean productBean1 = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			OrderVo orderVo = SqTradingCallService.createOrderVo(Arrays.asList(productBean1));
			
			OrderItemVo orderItemVo1 = orderVo.getOrderItems().get(0);
			
			orderItemVo1.setProductNum(2);
			orderItemVo1.setProductPrice(new BigDecimal("49.00"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService.createOrderItemVo(productBean1
					.getProductId(), productBean1.getCatalogList().get(1));
			
			orderItemVo2.setProductNum(3);
			orderItemVo2.setProductPrice(new BigDecimal("29.99"));
			
			orderVo.getOrderItems().add(orderItemVo2);
			
			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			
			placeOrderReq.setDiscount(new BigDecimal("93.99").negate());
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);

			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			orderItemPreApportionVo1.setDiscount(new BigDecimal("53.99").negate());
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			orderItemPreApportionVo2.setDiscount(new BigDecimal("40.00").negate());
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();	

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_087() {
		Logger.start(true, "渠道商一次下单一个旅游出行人，生产一个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			
//			AgentProductBean productBean = new AgentProductBean();
//			productBean.setCatalogList(Arrays.asList("c7728779"));
//			productBean.setGoodsOwnerId(500181307L);
//			productBean.setSellerId(500181307L);
//			productBean.setProductId("p4551768");
//			productBean.setSellerLoginId("5d6f289f53eb53001598aa29");

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			TravelerVo travelerVo = new TravelerVo();
			
			travelerVo.setTravelerPhone(TestDataManager.getPhoneNum());
			travelerVo.setTravelerName("autotest" + TestDataManager.getChineseName());
			travelerVo.setTravelerIdcard(TestDataManager.getCardId(20, 1));
			travelerVo.setTravelerDate(YMTDateUtil.getDate());
			travelerVo.setRemark("remark" + TestDataManager.randomStr(20));
			
			placeOrderReq.setTravelerVos(Arrays.asList(travelerVo));
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setFirstCategoryId(2657);

			OrderItemVo item = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_088() {
		Logger.start(true, "渠道商一次下单多个旅游出行人，生成多个订单");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			placeOrderReq.setAddressId(null);
			placeOrderReq.setAddress(null);
			
			TravelerVo travelerVo1 = new TravelerVo();
			
			travelerVo1.setTravelerPhone(TestDataManager.getPhoneNum());
			travelerVo1.setTravelerName("autotest" + TestDataManager.getChineseName());
			travelerVo1.setTravelerIdcard(TestDataManager.getCardId(20, 1));
			travelerVo1.setTravelerDate(YMTDateUtil.getDate());
			travelerVo1.setRemark("remark" + TestDataManager.randomStr(20));
			
			TravelerVo travelerVo2 = new TravelerVo();
			
			travelerVo2.setTravelerPhone(TestDataManager.getPhoneNum());
			travelerVo2.setTravelerName("autotest" + TestDataManager.getChineseName());
			travelerVo2.setTravelerIdcard(TestDataManager.getCardId(20, 1));
			travelerVo2.setTravelerDate(YMTDateUtil.getDate());
			travelerVo2.setRemark("remark" + TestDataManager.randomStr(20));
			
			TravelerVo travelerVo3 = new TravelerVo();
			
			travelerVo3.setTravelerName("autotest" + TestDataManager.getChineseName());
			travelerVo3.setTravelerIdcard(TestDataManager.getCardId(20, 1));
			
			placeOrderReq.setTravelerVos(Arrays.asList(travelerVo1, travelerVo2, travelerVo3));
			
			productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			OrderVo orderVo = SqTradingCallService.createOrderVo(Arrays.asList(productBean));
			
			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo);
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setFirstCategoryId(2657);

			OrderItemVo item1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo item2 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(1).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			
			item2.setOrderItemPreApportionVo(orderItemPreApportionVo2);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_089() {
		Logger.start(true, "渠道商一次下单一个旅游出行人，主出行人没有名称");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			TravelerVo travelerVo = new TravelerVo();
			
			travelerVo.setTravelerPhone(TestDataManager.getPhoneNum());
//			travelerVo.setTravelerName("autotest" + TestDataManager.getChineseName());
			travelerVo.setTravelerIdcard(TestDataManager.getCardId(20, 1));
			travelerVo.setTravelerDate(YMTDateUtil.getDate());
			travelerVo.setRemark("remark" + TestDataManager.randomStr(20));
			
			placeOrderReq.setTravelerVos(Arrays.asList(travelerVo));

			OrderItemVo item1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"travelerName:must not be null"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_090() {
		Logger.start(true, "渠道商一次下单一个旅游出行人，主出行人没有手机号");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			TravelerVo travelerVo = new TravelerVo();
			
//			travelerVo.setTravelerPhone(TestDataManager.getPhoneNum());
			travelerVo.setTravelerName("autotest" + TestDataManager.getChineseName());
			travelerVo.setTravelerIdcard(TestDataManager.getCardId(20, 1));
			travelerVo.setTravelerDate(YMTDateUtil.getDate());
			travelerVo.setRemark("remark" + TestDataManager.randomStr(20));
			
			placeOrderReq.setTravelerVos(Arrays.asList(travelerVo));
			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setFirstCategoryId(2657);

			OrderItemVo item1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_091() {
		Logger.start(true, "渠道商一次下单多个旅游出行人，副出行人没有名称");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			TravelerVo travelerVo = new TravelerVo();
			
			travelerVo.setTravelerPhone(TestDataManager.getPhoneNum());
			travelerVo.setTravelerName("autotest" + TestDataManager.getChineseName());
			travelerVo.setTravelerIdcard(TestDataManager.getCardId(20, 1));
			travelerVo.setTravelerDate(YMTDateUtil.getDate());
			travelerVo.setRemark("remark" + TestDataManager.randomStr(20));
			
			TravelerVo travelerVo2 = new TravelerVo();
			
//			travelerVo2.setTravelerName("autotest" + TestDataManager.getChineseName());
			
			placeOrderReq.setTravelerVos(Arrays.asList(travelerVo, travelerVo2));

			OrderItemVo item1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			item1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"travelerName:must not be null"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_092() {
		Logger.start(true, "渠道商一次下单一个商品,商品单价为20000，商品数×总金额大于等于5w，支持线下支付的订单，不被风控，下单成功");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO,
							20238699, productBean, (int) autotest_goodsOwnerId);

			OrderItemVo orderItemVo = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);

			orderItemVo.setProductPrice(new BigDecimal("20000"));
			orderItemVo.setProductNum(3);

			orderItemVo.setFreight(BigDecimal.ZERO);

			placeOrderReq.setSupportOfflinePay(true);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			
			orderItemVo.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();
			
			Thread.sleep(5000);

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_093() {
		Logger.start(true, "调价金额和分摊到商品上的调价金额不一致，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, (int) autotest_goodsOwnerId);
			
			OrderItemVo orderItemVo = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			
			orderItemVo.setProductPrice(new BigDecimal(productBean
					.getAgentCatalogPriceList().get(1).getAgentPrice()));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);
			
			placeOrderReq.setDiscount(new BigDecimal("10.00"));
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);

			OrderItemVo orderItemVo1 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(0);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemVo orderItemVo2 = placeOrderByApportionedAmountReq
					.getOrderGroups().get(0).getOrders().get(0).getOrderItems()
					.get(1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"调价金额和分摊到商品上的调价金额不一致"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_094() {
		Logger.start(true, "优惠金额和分摊到商品上的优惠券金额不一致，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId(), true);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0).setSellerPromotionApportions(sellerPromotionList);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(new BigDecimal("-3.99"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("11.99"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("-6.01"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("0.01"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"优惠金额和分摊到商品上的优惠金额不一致"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_095() {
		Logger.start(true, "优惠金额和分摊到商品上的优惠金额不一致，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId(), true);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0).setSellerPromotionApportions(sellerPromotionList);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(new BigDecimal("-3.99"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("14.99"));
			orderItemPreApportionVo1.setSellerPromotionId(sellerPromotion1.getId());
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("9.98"));
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("-6.01"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("-0.01"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("0.02"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"优惠金额和分摊到商品上的优惠金额不一致"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_096() {
		Logger.start(true, "优惠金额对应的优惠id未传入，下单失败");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, productBean.getSellerId(), true);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			
			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(new BigDecimal(15));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean
							.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0).setSellerPromotionApportions(sellerPromotionList);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(new BigDecimal("-3.99"));
			orderItemPreApportionVo1.setSellerPromotionAmount(new BigDecimal("14.99"));
			orderItemPreApportionVo1.setSellerCouponAmount(new BigDecimal("9.98"));
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("-6.01"));
			orderItemPreApportionVo2.setSellerPromotionAmount(new BigDecimal("0.01"));
			orderItemPreApportionVo2.setSellerPromotionId(sellerPromotion1.getId());
			orderItemPreApportionVo2.setSellerCouponAmount(new BigDecimal("0.02"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"请传入优惠金额对应的优惠id"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PlaceOrderByApportionedAmount_097() {
		Logger.start(true, "代购神器继承代理，预分摊信息使用订单折扣，下单失败");
		try {
			
			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createInheritedProxychain((int) mchId, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
							productBean, (int) mchId, false);
			
			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			orderItemVo1.setProductPrice(new BigDecimal(13));
			orderItemVo1.setFreight(BigDecimal.ZERO);
			orderItemVo1.setProductNum(1);
			
			OrderVo orderVo2 = SqTradingCallService.createOrderVo(Arrays.asList(productBean));
			
			OrderItemVo orderItemVo2 = orderVo2.getOrderItems().get(0);
			
			orderItemVo2.setCatalogId(productBean.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));
			orderItemVo2.setProductPrice(new BigDecimal(12));
			orderItemVo1.setFreight(BigDecimal.ZERO);
			orderItemVo2.setProductNum(1);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);
			
			placeOrderByApportionedAmountReq = new PlaceOrderByApportionedAmountReq();
			PlaceOrderByApportionedAmountReq.fatherToChild(placeOrderReq, placeOrderByApportionedAmountReq);
			
			OrderItemPreApportionVo orderItemPreApportionVo1 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo1.setDiscount(BigDecimal.ONE);
			orderItemPreApportionVo1.setTaxFee(BigDecimal.TEN);
			
			orderItemVo1.setOrderItemPreApportionVo(orderItemPreApportionVo1);
			
			OrderItemPreApportionVo orderItemPreApportionVo2 = new OrderItemPreApportionVo();
			
			orderItemPreApportionVo2.setDiscount(new BigDecimal("9.00"));
			orderItemPreApportionVo2.setTaxFee(BigDecimal.TEN);
			
			orderItemVo2.setOrderItemPreApportionVo(orderItemPreApportionVo2);

			placeOrderByApportionedAmountCall.setData(placeOrderByApportionedAmountReq);
			placeOrderByApportionedAmountCall.callService();

			Logger.verifyEquals(400, placeOrderByApportionedAmountCall.getCode(), "校验code");
			Logger.verifyEquals(100, placeOrderByApportionedAmountCall.getBcode(), "校验bcode");

			Logger.verifyEquals(
					true,
					placeOrderByApportionedAmountCall.getMsg().contains(
							"您是分销小店无法改价，请联系渠道商！"), "校验msg");
			Logger.verifyEquals(false,
					placeOrderByApportionedAmountCall.getData().getBoolean("success"), "校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	public static void main(String[] args) {
		
//		Ts_PlaceOrderByApportionedAmount test = new Ts_PlaceOrderByApportionedAmount();
//		
//		OrderPo orderPo = orderShardingWapper.selectOrderbyOrderId(7439978699L);
//		List<OrderDetailPo> orderDetailList = orderShardingWapper.selectOrderDetailbyOrderId(7439978699L);
//		
//		test.verifyShenqiSellerProfit(orderPo, orderDetailList);
		
		System.out.println("Failed to fetch proxy chain. catalogIds:[c7155207, c7155214]"
				.contains("Faield to fetch proxy chain"));
	}
}
